0
我需要這個多維數組轉換爲一個簡單的數組。php多維數組到簡單數組
Array
(
[0] => Array
(
[id_zub] => 1
[name] => Backen
)
[1] => Array
(
[id_zub] => 2
[name] => Kochen
)
)
一個簡單的數組:
array(
[id_zub] => 1
[name] => Backen
[id_zub] => 2
[name] => Kochen
)
功能array_flattern($陣列){
foreach($array as $key=> $value){
if(is_array($value)){
$this->array_flattern($value);
}
else{
$this->result[$key] = $value;
}
}
}
功能給了我這樣的結果:
Array
(
[id_zub] => 2
[name] => Kochen
)
因爲PHP會覆蓋重複鍵的值,你不能創建類似數組中的鍵... – 2013-07-13 19:21:38