Nasıl bir multi-dizi tuşları "yeniden düzenleyebilir" olabilir? Örneğin, ben:
$arr["abc"][0] = "val1";
$arr["abc"][1] = "val2";
$arr["abc"][2] = "val3";
$arr["xyz"][0] = "val4";
$arr["xyz"][1] = "val5";
$arr["xyz"][2] = "val6";
Ve ben olmak istiyorum:
$arr[0]["abc"] = "val1";
$arr[0]["xyz"] = "val4";
$arr[1]["abc"] = "val2";
$arr[1]["xyz"] = "val5";
$arr[2]["abc"] = "val3";
$arr[2]["xyz"] = "val6";
Benim şu anki çabadır:
foreach ($arr as $param => $num) foreach ($num as $val) $newArr[$num][$param] = $val;
but it doesn't seem to be working. Any help would be appreciated.
EDIT:
Specifically, I'm trying to loop through all elements submitted on $_FILES
, as they all need the same thing done to them. By default, when there is more than one <input type="file" name="filedata[]" />
in a form, they go to $_FILES["filedata"]["name"][$index]
. ("name"
or any other parameter), so I cant just loop through every $_FILES["filedata"]
to get at everything; thus, I need the keys of $_FILES["filedata"]
reversed.