<!DOCTYPE html> <html lang="en-US"> <head> <title>My Grocery List</title> <meta name="description" content="A table for a menu"> <meta name="author" content="Mark Silva"> <meta charset="utf-8"> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> </head> <body> <h1>My Menu</h1> <table> <caption>Grocery</caption> <tr> <th>Item</th ><th>Price</th> </tr> <?php $groc_array = ["Toilet Paper" => 2.00, "Chips" => 1.00, "Shampoo" => 5.00]; foreach($groc_array as $key => $value) { echo "<tr> <td>$key</td><td>$value</td> </tr>"; } ?> </table> </body> </html>
<head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> </head>
<body> <table> <caption>Late Night Snack</caption> <tr> <td>Item</td> <td>Price</td> </tr> <?php $grocery_items = [ "Milk" => 6.15 "Cake" => 5.45 "Cookies" => 4.25 ]; foreach($grocery_items as $key => $value{ echo"<tr><td>$key</td><td>$$value</td></tr>"; } ?> </table> </body></html>
<?php $grocery = ["chicken", "beef", "lamb"]; $length = count($grocery); for ($i = 0; $i < $length; $i++){ echo $grocery[$i], "," . "\n"; } ?> </body></html>
<html> <head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> </head>
<body> <h2>Grocery List</h2> <?php $grocerylist = ["Tomato" => 3, "Potato" => 4, "Egg" => 5]; ?> <table> <caption>Grocery List</caption> <tr><th>Item</th><th>Price</th></tr> <?php foreach($grocerylist as $key => $value) { echo "<tr><td>$key</td><td>$value</td></tr>"; } ?> </table> </body> </html>
<!DOCTYPE html> <html> <head> <title>Grocery List</title> <style> table, tr, th, td { border: 1px solid black; border-collapse: collapse; } </style> </head>
<body> <caption>Grocery List</caption> <table> <tr> <th>Item</th><th>Price</th> </tr>
<?php$grocery_list = [ "eggs" => 5.00, "milk" => 3.00, "bread" => 10.00 ]; foreach($grocery_list as $key => $value) { echo "<tr><td>$key</td><td>$value</td></tr>"; } ?>
</table>
</body></html>
<tr> <th>Item</th> <th>Cost</th> </tr><?php
$grocery_items = [ "Milk" => 2.49, "Salad" => 2.18, "Ketchup" => 3.99 ];
foreach($grocery_items as $item => $value) { echo "<tr>"; echo "<td>". $item ."</td>"; echo "<td>$". $value ."</td>"; echo "</tr>"; }?> </table> </body> </html>
<!DOCTYPE html> <html> <head> </head> <body> <table> <caption>groceries</caption> <tr><th>item</th><th>price</th></tr> <?php $a = ["eggs" => 2.99, "apples" => 3.99, "bananas" => 1.99]; foreach ($a as $item => $price) { echo "<tr><td>$item</td><td>$price</td></tr>"; } ?> </table></body> </html> (Edited: 2021-02-24)
<head> <title>Grocery List</title> </head> <body> <h3>Grocery List</h3> <table> <tr> <th>Item</th> <th>Price</th> </tr> <?php
$item_price = [ "Shrimp" => 7.49, "Cheese" => 6.99, "Spam" => 4.99 ];
foreach($item_price as $item => $price) { echo "<tr>"; echo "<td>". $item ."</td>"; echo "<td>$". $price ."</td>"; echo "</tr>"; } ?> </table> </body></html>
"Banana" => 3.99, "Mango" => 4.49, "Apple" => 6.99];