当前位置: 首页>>代码示例>>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;未经允许,请勿转载。