Created
October 25, 2011 17:22
-
-
Save dev4dev/1313553 to your computer and use it in GitHub Desktop.
pop file information from $_FILES array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pop_file(&$files) | |
{ | |
## single file | |
if (!is_array($files['name'])) { | |
$temp = $files; | |
$files = array('name' => array()); | |
return $temp; | |
} | |
## as array | |
if (count($files['name']) == 0) { | |
return NULL; | |
} | |
$keys = array_keys($files); | |
$out = array(); | |
foreach ($keys as $key) { | |
$out[$key] = array_shift($files[$key]); | |
} | |
return $out; | |
} | |
if (count($_FILES) > 0) { | |
while ($file = pop_file($_FILES['files'])) { | |
echo '<pre>';print_r($file); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment