Make use of some of the PHP loop shorthand to create HTML for a restaurant menu. Practice using the different loop types with HTML.
-
-
Save Dyrits/cd27ab2fa78f4c448458e34be7b1af15 to your computer and use it in GitHub Desktop.
Repetitive Cafe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$drinks = [ | |
"Latte" => 3.99, | |
"Coffee" => 2.00, | |
"Tea" => 2.50, | |
"Mocha" => 4.50 | |
]; | |
$pastries = [ | |
"Croissant", | |
"Muffin", | |
"Slice of Pie", | |
"Slice of Cheesecake", | |
"Cupcake", | |
"Brownie" | |
]; | |
?> | |
<h1>Welcome to the Repetitive Cafe</h1> | |
<h3>Drinks!</h3> | |
<ul> | |
<?php foreach($drinks as $drink=>$price):?> | |
<li><?="$drink: $$price"?></li> | |
<?php endforeach;?> | |
</ul> | |
<h3>Pastries! ($2 each)</h3> | |
<ul> | |
<?php foreach($pastries as $pastrie):?> | |
<li><?="$pastrie"?></li> | |
<?php endforeach;?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment