note 53479 deleted from features.file-upload.multiple by salathe
| From: | salathe@php.net | Date: | Fri, 03 Jan 2014 18:50:34 +0000 |
| Subject: | note 53479 deleted from features.file-upload.multiple by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198099@lists.php.net to get a copy of this message | ||
Note Submitter: bishop
----
Elaboration on phpuser at gmail dot com reArrayFiles() function (which assumed sequential, integer
keys and uni-dimensional), this function will work regardless of key and key depth:
<?php
// information grouper
function groupFileInfoByVariable(&$top, $info, $attr) {
if (is_array($info)) {
foreach ($info as $var => $val) {
if (is_array($val)) {
groupFileInfoByVariable($top[$var], $val, $attr);
} else {
$top[$var][$attr] = $val;
}
}
} else {
$top[$attr] = $info;
}
return true;
}
// usage
$newOrdering = array ();
foreach ($_FILES as $var => $info) {
foreach (array_keys($info) as $attr) {
groupFileInfoByVariable($newOrdering, $info[$attr], $attr);
}
}
// $newOrdering holds the updated order
?>