當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Info::getArrayDepth方法代碼示例

本文整理匯總了PHP中Info::getArrayDepth方法的典型用法代碼示例。如果您正苦於以下問題:PHP Info::getArrayDepth方法的具體用法?PHP Info::getArrayDepth怎麽用?PHP Info::getArrayDepth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Info的用法示例。


在下文中一共展示了Info::getArrayDepth方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: upload

 /**
  * Call move() method for each given file
  * @return array of filenames that were uploaded
  */
 protected function upload()
 {
     $input = $this->input;
     // if $_FILES array contains fields with multiple attribute
     if (Info::getArrayDepth($input) === 3) {
         foreach ($input as $field => $filebatch) {
             // if current field allows for MULTIPLE files upload
             if (Info::getArrayDepth($filebatch) === 2) {
                 foreach ($filebatch as $file => $contents) {
                     $this->move($contents);
                 }
                 // if current field allows for only SINGLE file upload
             } else {
                 $contents = $filebatch;
                 $this->move($contents);
             }
         }
         // if $_FILES array doesn't contain fields with multiple attribute at all
     } else {
         foreach ($input as $field => $contents) {
             $this->move($contents);
         }
     }
     return $this->results;
 }
開發者ID:adiachenko,項目名稱:bookshop,代碼行數:29,代碼來源:Upload.php

示例2: cleanUpInput

 /**
  * Recursively examines $_FILES array depth and rebuilds it accordingly:
  *
  *    $_FILES array
  *        [fieldname for single file upload field] = array with file properties
  *        [fieldname for multiple file upload field] = [
  *                [fileindex] = array with file properties
  *                [fileindex] = array with file properties
  *                [fileindex] = array with file properties
  *        ]
  *        [fieldname for single file upload field] = array with file properties
  *
  * This structure makes much more sense for the purpose of validation.
  *
  *
  * @param array $files - original $_FILES
  * @return array $new - reformed $_FILES
  */
 protected function cleanUpInput($files)
 {
     $new = [];
     foreach ($files as $fieldname => $contents) {
         if (Info::getArrayDepth($contents) === 2) {
             foreach ($contents as $key => $filebatch) {
                 foreach ($filebatch as $fileindex => $value) {
                     $new[$fieldname][$fileindex][$key] = $value;
                 }
             }
         } else {
             foreach ($contents as $key => $value) {
                 $new[$fieldname][$key] = $value;
             }
         }
     }
     return $new;
 }
開發者ID:adiachenko,項目名稱:bookshop,代碼行數:36,代碼來源:ValidateFile.php


注:本文中的Info::getArrayDepth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。