我有以下代码。在最后一个 foreach 中,我想在数组中添加$last_array
和$last2_array
作为键/值对。$display
这是我尝试过的:
$display[] = array($last_array => $last2_array); //doesn't work
print_r($display); //under the loop prints nothing
编码:
$display=array();//declare the array outside the loop
foreach ($array as $arrays){
foreach ($arrays as $elem) {
unset($elem['id']); //Removes id key
unset($elem['idno']); //Removes idno key
foreach ($elem as $last_array => $last2_array) {
//code here
#echo $last_array. ": ".$last2_array."<br>";//This prints data, it's not empty.
}
echo "<br>";
}
}
提前致谢。