0

How do I print out the following from the code below:

Ford, Mustang, 2010

Chevrolet, Silverado, 2008

Dodge, Charger, 2012

echo "Section 1: Array of Structures";
$cars = array (
  array('Ford','Mustang',2010),
  array('Chevolet','Silverado',2008),
  array('Dodge','Charger',2012)
);
for ($i = 0; $i < count($cars); $i++) {
  $innerArrayLength = count($cars[$i]);
  for ($j = 0; $j < $innerArrayLength; $j++) {
  }
}
echo "<br/>";
foreach($cars as $data){
    echo $data;
    echo "<br/>";
  }

1 Answers1

0

You can use this code....

echo "Section 1: Array of Structures\n";
$cars = array (
    array('Ford','Mustang',2010),
    array('Chevolet','Silverado',2008),
    array('Dodge','Charger',2012)
);
foreach ($cars as $car){
   echo implode(",", $car)."\n";
}
Amir Azizi
  • 61
  • 4