I have the following code. In the last foreach I'd like to add $last_array and $last2_array as key/value pairs inside $display array. Here's what I tried:
$display[] = array($last_array => $last2_array); //doesn't work
print_r($display); //under the loop prints nothing
The code:
$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>";
}
}
Thanks in advance.
&:foreach ($array as &$arrays){$displayprints blank so how will it work anyway? how are you constructing the array$display?$display=array(1,2,3);you want to add 4 and 5array_push($display, 4, 5);array push$arraydata?