Skip to content

Instantly share code, notes, and snippets.

@vladislav805
Last active January 3, 2017 17:15
Show Gist options
  • Save vladislav805/27920375bd7874410baf0f88f50f9710 to your computer and use it in GitHub Desktop.
Save vladislav805/27920375bd7874410baf0f88f50f9710 to your computer and use it in GitHub Desktop.
Rearrange $_FILES from { name = [1, 2, 3], size = [1, 2, 3], ... } to [ { name = 1, size = 1 }, { name = 2, size = 2 }, ... ]
<?
function reArrayFiles(&$files) {
$result = [];
$keys = array_keys($files);
for ($i = 0, $l = sizeof($files["name"]); $i < $l; $i++) {
foreach ($keys as $key) {
$result[$i][$key] = $files[$key][$i];
};
};
return $result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment