本文整理汇总了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;
}
示例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;
}