本文整理匯總了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;
}