array(3) {
[0]=>
array(4) {
["Field1"]=>
string(8) "80000007"
["Field2"]=>
string(16) "O70000006"
["Field3"]=>
string(0) ""
["Field4"]=>12345
string(0) ""
}
[1]=>
array(4) {
["Field1"]=>
string(8) "80000008"
["Field2"]=>
string(16) "O70000007"
["Field3"]=>
string(0) ""
["Field4"]=>78965
string(0) ""
}
[2]=>
array(4) {
["Field1"]=>
string(8) "80000009"
["Field2"]=>
string(16) "H80000006"
["Field3"]=>
string(0) ""
["Field4"]=>12345
string(0) ""
}
}
我有上面的數組我想將這些數組項存儲到另一個臨時數組中並使用它。以下是IAM做如何用這組項目創建一個動態數組
$arr_tmp = array();
foreach ($result['record'] as $key => $value){
$arr_tmp['Field1'] = $value['Field1'];
$arr_tmp['Field2'] = $value['Field2'];
$arr_tmp['Field3'] = $value['Field3'];
$arr_tmp['Field4'] = $value['Field4'];
}
當我盡訴ar_dump($arr_tmp)
。 Iam只獲取數組中的最後一條記錄。在使用foreach循環時,我需要在這個$ arr_tmp中設置相同的結果集,以便我可以向該數組添加更多項目。