我有一個數組,其中有另一個數組。我需要取消設置子數組的索引。取消設置另一個數組內的數組索引
array
0 =>
array
'country_id' => string '1' (length=1)
'description' => string 'test' (length=4)
1 =>
array
'country_id' => string '2' (length=1)
'description' => string 'sel' (length=5)
2 =>
array
'country_id' => string '3' (length=1)
'description' => string 'soul' (length=5)
現在我需要取消設置主數組的所有三個索引中的country_id
。我使用的PHP和我最初認爲未設置會做,直到我意識到我的數組嵌套。
我該怎麼做?
'的foreach($陣列作爲&$ element){unset($ element ['country_id'];}' – Steve 2014-09-10 12:33:21
'foreach($ array as&$ sub)unset($ sub ['country_id']);' – 2014-09-10 12:33:24
[PHP - unset in一個多維數組](http:// stackoverflow的.com /問題/ 7260468/PHP-未設定功能於一個-多維陣列) – Joanvo 2014-09-10 12:52:49