0
所以我目前有一個看起來像這樣的數組。分組多維數組
Array
(
[name] => Array
(
[1] => Array
(
[0] => 500aqua.jpg
)
[2] => Array
(
[0] => 500beige.jpg
[1] => 500beige-zoom.jpg
)
[3] => Array
(
[0] => P1040485.JPG
[1] => P1040486.JPG
[2] => P1040487.JPG
)
)
[type] => Array
(
[1] => Array
(
[0] => image/jpeg
)
[2] => Array
(
[0] => image/jpeg
[1] => image/jpeg
)
[3] => Array
(
[0] => image/jpeg
[1] => image/jpeg
[2] => image/jpeg
)
)
[tmp_name] => Array
(
[1] => Array
(
[0] => C:\xampp\tmp\php5F9.tmp
)
[2] => Array
(
[0] => C:\xampp\tmp\php5FA.tmp
[1] => C:\xampp\tmp\php5FB.tmp
)
[3] => Array
(
[0] => C:\xampp\tmp\php60C.tmp
[1] => C:\xampp\tmp\php63B.tmp
[2] => C:\xampp\tmp\php66B.tmp
)
)
[error] => Array
(
[1] => Array
(
[0] => 0
)
[2] => Array
(
[0] => 0
[1] => 0
)
[3] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
)
[size] => Array
(
[1] => Array
(
[0] => 133659
)
[2] => Array
(
[0] => 148940
[1] => 211420
)
[3] => Array
(
[0] => 3939511
[1] => 4742470
[2] => 4345899
)
)
)
而且我希望它看起來像這樣
Array
(
[0] => Array
(
[0] => Array
(
[name] => 500aqua.jpg
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php5F9.tmp
[error] => 0
[size] => 133659
)
)
[1] => Array
(
[0] => Array
(
[name] => 500beige.jpg
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php5FA.tmp
[error] => 0
[size] => 148940
)
[1] => Array
(
[name] => 500beige-zoom.jpg
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php5FB.tmp
[error] => 0
[size] => 211420
)
)
[2] => Array
(
[0] => Array
(
[name] => P1040485.JPG
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php60C.tmp
[error] => 0
[size] => 148940
)
[1] => Array
(
[name] => P1040486.JPG
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php63B.tmp
[error] => 0
[size] => 148940
)
[2] => Array
(
[name] => P1040487.JPG
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php66B.tmp
[error] => 0
[size] => 148940
)
)
)
我嘗試下面的代碼,但它似乎只得到每個最後3中的陣列。
foreach ($data as $d) {
foreach ($d as $key => $e) {
foreach ($e as $key2 => $f) {
$result[$key2][$key] = $f;
}
}
}
等預先
Array
(
[0] => Array
(
[name] => P1040485.JPG
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php60C.tmp
[error] => 0
[size] => 3939511
)
[1] => Array
(
[name] => P1040486.JPG
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php63B.tmp
[error] => 0
[size] => 4742470
)
[2] => Array
(
[name] => P1040487.JPG
[type] => image/jpeg
[tmp_name] => C:\xampp\tmp\php66B.tmp
[error] => 0
[size] => 4345899
)
)
感謝。
輝煌,傻我。 –