I have this some arrays that look like this,
$array = Array(
'Homer' => Array
(
'id' => 222,
'size' => 12
),
'Bart' => Array
(
'id' => 333,
'size' => 3
)
);
I would like to echo Homer: id is 222, size is 12
then in the next line echo Bart: id is 333, size is 3 using a foreach loop as key and values.
So i basically want to echo all the Simpsons character names which have their id and size next their names.
I tired this but it printed homer too many times and it even used Bart's id and size at one point.
foreach( $array as $billdate => $date) {
foreach( $date as $k => $v) {
echo $billdate; // Prints Homer and bart
foreach($array as $innerArray){
foreach($innerArray as $key => $value){
echo "[". $key ."][". $value ."] <br/>";
}}
}
}
Thanks in advance.