Skip to content

Instantly share code, notes, and snippets.

@dev4dev dev4dev/gist:1313553
Created Oct 25, 2011

Embed
What would you like to do?
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
You can’t perform that action at this time.