<?php
$arr = [
"name" => [
"0" => "third.png",
"1" => "second.png",
"2" => "first.png",
],
"type" => [
"0" => "image/png",
"1" => "image/png",
"2" => "image/png",
],
"tmp_name" => [
"0" => "/opt/lampp/temp/phpOPmQcB",
"1" => "/opt/lampp/temp/phpk0j1yp",
"2" => "/opt/lampp/temp/phpS2mhVd",
],
"error" => [
"0" => 0,
"1" => 0,
"2" => 0,
],
"size" => [
"0" => 179440,
"1" => 102238,
"2" => 75915,
],
];
$keys = array_keys($arr);
$count = count($arr[$keys[0]]);
for($i = 0; $i<$count; $i++){
foreach($keys as $val){
$new[$i][$val] = $arr[$val][$i];
}
}
var_dump($new);
- Output for 5.6.38, 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- array(3) {
[0]=>
array(5) {
["name"]=>
string(9) "third.png"
["type"]=>
string(9) "image/png"
["tmp_name"]=>
string(25) "/opt/lampp/temp/phpOPmQcB"
["error"]=>
int(0)
["size"]=>
int(179440)
}
[1]=>
array(5) {
["name"]=>
string(10) "second.png"
["type"]=>
string(9) "image/png"
["tmp_name"]=>
string(25) "/opt/lampp/temp/phpk0j1yp"
["error"]=>
int(0)
["size"]=>
int(102238)
}
[2]=>
array(5) {
["name"]=>
string(9) "first.png"
["type"]=>
string(9) "image/png"
["tmp_name"]=>
string(25) "/opt/lampp/temp/phpS2mhVd"
["error"]=>
int(0)
["size"]=>
int(75915)
}
}
preferences:
81.88 ms | 409 KiB | 5 Q