這是我的陣列正在轉換多維數組一維的笨插入
array (size=5)
0 =>
array (size=2)
'key' => string 'PresentAddressDisrict' (length=21)
'value' => string '1' (length=1)
1 =>
array (size=2)
'key' => string 'ParmanentAddressDistrict' (length=24)
'value' => string '2' (length=1)
2 =>
array (size=2)
'key' => string 'Board' (length=5)
'value' => string '1' (length=1)
3 =>
array (size=2)
'key' => string 'FieldChoice' (length=11)
'value' => string '1' (length=1)
4 =>
array (size=2)
'key' => string 'Gender' (length=6)
'value' => string '1' (length=1)
嘗試多種解決方案,如:
- 壓扁的基於陣列
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($a));
foreach($it as $v) {
echo $v, " ";
}
- using loops:
foreach ($a as $v1) {
foreach ($v1 as $v2) {
echo "$v2\n";
}
}
,但沒有得到期望的結果,仍然找路。
需要的是:
array('PresentAddressDisrict' => 1, 'ParmanentAddressDistrict' => 2, 'Board' => 1, 'FieldChoice' => 1, 'Gender' => 1)
請幫助我。
我覺得你首先,我刪除我的答案和投票了 – Naumov