Loop Through An Array In PHP with 2 or more properties

You can either add multiple properties by adding multiple elements within a sub-array

$foodArray = [['name' => 'Apple', 'color' => 'Yellow'], 
              ['name' => 'Banana', 'color' => 'yellow']];

foreach($foodArray as $fruit) {
    echo $fruit['name']." - ".$fruit['color']." 
"; }

Or if you just need these two properties, you can use the key as the name, and the value as the color.

$foodArray = ['Apple' => 'green', 'Banana' => 'yellow'];
foreach($foodArray as $fruit => $color) {
    echo $fruit." - ".$color ." 
"; }