我不知道如何正確地展平這個(gè)數(shù)組。因此,當(dāng)我使用 array_unique 展平時(shí),我松開(kāi)了鍵。所以,這是原始數(shù)組: array:9 [ 0 => array:1 [ 2 => "Opnam" ] 1 => array:1 [ 2 => "Opnam" ] 2 => array:1 [ 2 => "Opnam" ] 3 => array:1 [ 3 => "Voem" ] 4 => array:1 [ 8 => "And" ] 5 => array:1 [ 6 => "Vei" ] 6 => array:1 [ 6 => "Vei" ] 7 => array:1 [ 8 => "And" ] 8 => array:1 [ 8 => "And" ]]The is the expected output:array:[ 2 => "Opnam" 3 => "Voem" 6 => "Vei" 8 => "And"]提前致謝。
1 回答

守候你守候我
TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊
獲取內(nèi)部數(shù)組的key和value,作為結(jié)果的key和value。
$result = [];
foreach ($original as $inner) {
foreach ($inner as $key => $value) {
$result[$key] = $value;
}
}
- 1 回答
- 0 關(guān)注
- 218 瀏覽
添加回答
舉報(bào)
0/150
提交
取消