note 109958 added to reserved.variables.files
| From: | sergio_ag at terra dot com dot br | Date: | Wed, 05 Sep 2012 20:09:35 +0000 |
| Subject: | note 109958 added to reserved.variables.files | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190522@lists.php.net to get a copy of this message | ||
A nice trick to reorder the $_FILES array when you use a input name as array is:
function diverse_array($vector) {
$result = array();
foreach($vector as $key1 => $value1)
foreach($value1 as $key2 => $value2)
$result[$key2][$key1] = $value2;
return $result;
}
will transform this:
array(1) {
["upload"]=>array(2) {
["name"]=>array(2) {
[0]=>string(9)"file0.txt"
[1]=>string(9)"file1.txt"
}
["type"]=>array(2) {
[0]=>string(10)"text/plain"
[1]=>string(10)"text/html"
}
}
}
into:
array(1) {
["upload"]=>array(2) {
[0]=>array(2) {
["name"]=>string(9)"file0.txt"
["type"]=>string(10)"text/plain"
},
[1]=>array(2) {
["name"]=>string(9)"file1.txt"
["type"]=>string(10)"text/html"
}
}
}
just do:
$upload = diverse_array($_FILES["upload"]);
----
Server IP: 69.147.83.197
Probable Submitter: 201.49.104.108
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.files.php
Edit -- https://master.php.net/note/edit/109958
Del: integrated -- https://master.php.net/note/delete/109958/integrated
Del: useless -- https://master.php.net/note/delete/109958/useless
Del: bad code -- https://master.php.net/note/delete/109958/bad+code
Del: spam -- https://master.php.net/note/delete/109958/spam
Del: non-english -- https://master.php.net/note/delete/109958/non-english
Del: in docs -- https://master.php.net/note/delete/109958/in+docs
Del: other reasons-- https://master.php.net/note/delete/109958
Reject -- https://master.php.net/note/reject/109958
Search -- https://master.php.net/manage/user-notes.php