[Solved] How do I add a Array to my php variables, loops wont work with arrays


As an example (style and add to it as needed)

$cars[] = ['name'  => 'HRV',
           'price' => 'CAD-$23300',
           'img'   => 'http://direct.automobiles.honda.com/images/2016/hr-v/exterior-gallery-new/2016-honda-hrv-front-view.jpg',
           'desc'  => 'HRV is a mini suv made by Honda',
           ];
$cars[] = ['name'  => 'CHR' ,
           'price' => 'CAD-$23675' ,
           'img'   => 'https://d1bxbrgbmu84na.cloudfront.net/wp-content/uploads/2019/08/16093812/CHR.jpg' ,
           'desc'  => 'RDX is a large SUV made by Acura' ,
           ];

echo '<h1>My favourite Cars</h1>';

foreach ($cars as $detail) {

echo '<h2>"https://stackoverflow.com/questions/58067476/. $detail["name']  . '<p>' . 
              $detail['price'] . '<p>' . 
              $detail['desc']  . '<br>' . 
'<img src="https://stackoverflow.com/questions/58067476/. $detail["img']   . '</p></h2>';

}

3

solved How do I add a Array to my php variables, loops wont work with arrays