Skip to content

Instantly share code, notes, and snippets.

@dev4dev
Created October 25, 2011 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dev4dev/1313553 to your computer and use it in GitHub Desktop.
Save dev4dev/1313553 to your computer and use it in GitHub Desktop.
pop file information from $_FILES array
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