note 118180 added to features.file-upload.multiple

From: Date: Wed, 21 Oct 2015 14:20:36 +0000
Subject: note 118180 added to features.file-upload.multiple
Groups: php.notes 
Request: Send a blank email to php-notes+get-203998@lists.php.net to get a copy of this message
Recursive solution for complex situations (supports any nested arrays including indexed arrays) function getFixedFilesArray() { $walker = function ($arr, $fileInfokey, callable $walker) { $ret = array(); foreach ($arr as $k => $v) { if (is_array($v)) { $ret[$k] = $walker($v, $fileInfokey, $walker); } else { $ret[$k][$fileInfokey] = $v; } } return $ret; }; $files = array(); foreach ($_FILES as $name => $values) { // init for array_merge if (!isset($files[$name])) { $files[$name] = array(); } if (!is_array($values['error'])) { // normal syntax $files[$name] = $values; } else { // html array feature foreach ($values as $fileInfoKey => $subArray) { $files[$name] = array_replace_recursive($files[$name], $walker($subArray, $fileInfoKey, $walker)); } } } return $files; } ---- Server IP: 72.52.91.14 Probable Submitter: 37.9.129.6 ---- Manual Page -- http://php.net/manual/en/features.file-upload.multiple.php Edit -- https://master.php.net/note/edit/118180 Del: integrated -- https://master.php.net/note/delete/118180/integrated Del: useless -- https://master.php.net/note/delete/118180/useless Del: bad code -- https://master.php.net/note/delete/118180/bad+code Del: spam -- https://master.php.net/note/delete/118180/spam Del: non-english -- https://master.php.net/note/delete/118180/non-english Del: in docs -- https://master.php.net/note/delete/118180/in+docs Del: other reasons-- https://master.php.net/note/delete/118180 Reject -- https://master.php.net/note/reject/118180 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203998) next »