Hi,
I have a problem with the foreach loop, the values of the variables don’t echo in the webpage.
What print normally :
the values of the variables in the lessons,
and the other loops in the lessons and in the projects.
But the foreach loops in the projects (“Repetitive cafe” and “FizzBuzz”), don’t print at all.
Thanks if someone has an idea
My code :
<?php
$drinks = [
"cafe"=>1.5,
"chocolate"=>1.5,
"noisette"=>1.5,
"latte"=>1.5,
"coca"=>1.5,
"sirop citron"=>1,
];
$pastries = [
"tarte pommes",
"eclair chocolat",
"muffin chocolat",
"cookie",
"croissant maxi",
"pain au chocolat maxi",
"donut chocolat"
];
?>
<h1>Welcome to the Repetitive Cafe</h1>
<h3>Drinks!</h3>
<ul>
<?php foreach($drinks as $drink=>$price):
<li><?=$drink?> at <?=$price?>€</li><br>
<?php endforeach?>
</ul>