我有了這個陣列PHP合併多維數組成爲一個
array:2 [
0 => array:2 [
"monday_open" => "10:00:00"
"monday_close" => "20:00:00"
]
1 => array:2 [
"tuesday_open" => "00:00:00"
"tuesday_close" => "00:00:00"
]
]
我怎樣才能將它們組合起來成爲:
array:4 [
"monday_open" => "10:00:00"
"monday_close" => "20:00:00"
"tuesday_open" => "00:00:00"
"tuesday_close" => "00:00:00"
]
我一直在使用array_walk_recrusive嘗試,但它不還給我鍵名:
array_walk_recursive($array, function ($v) use (&$arrayFlat) {
$arrayFlat[] = $v;
});
我已經試過這一個了,但得到的結果相同array_walk_recrusive:
iterator_to_array(new RecursiveIteratorIterator(new RecursiveArrayIterator($array)), 0)
結果:
array:4 [
0 => "10:00:00"
1 => "20:00:00"
2 => "00:00:00"
3 => "00:00:00"
]
是否有任何其他的方式來保持關鍵價值?
你試過的答案! – 6339