Jump to content

[SOLVED] Help with modifying an array!


Recommended Posts

Hi sorry for another topic, just in dire help.

 

Here is my array stored in menu_data.php:

<?php

$days = array();

function myarray()
{
global $days;
$days = array
	(
  		"Monday"=>array
  			(
  			"Chicken Burger",
  			"Veal Schnitzel",
  			"Onion Rings",
  			"Hot Potato"
  			),
  		"Tuesday"=>array
  			(
  			"Steak Sandwich",
  			"Chicken Pasta",
  			"Pork Chop",
  			"Taco"
  			),
  		"Wednesday"=>array
  			(
  			"Chicken and Chips",
			"Beef Casserole",
  			"Pasta",
  			"Lasagne"
  			),
  		"Thursday"=>array
  			(
  			"Fish and Chips",
  			"Tuna Pattie",
  			"Chicko Roll",
  			"Hot Dog"
  			),
   		"Friday"=>array
  			(
  			"Nachos",
  			"Tuna Pattie",
  			"Maccaroni Cheese",
  			"Bacon and Eggs"
  			)
	);

}

?>

 

and I use this array to print a menu from it on print_menu.php:

<?php

include("menu-data.php");
myarray();

// Print menu. 
echo "<h1><u>Menu</u></h1>";

foreach ($days as $day => $meals)
{
echo "<li><b>" . $day . "</b><ul>";

foreach ($meals as $meal)
	{
		echo "<li>" . $meal . "</li>";
	}

echo "</ul></li>";
}

?>

 

This is for a university assignment, now all of a sudden they've gone:

Stage 6 - Prices

Modify menu_data.php so that it also stores the prices for the courses. Hint: You will probably need to add an extra array to do this. Modify print_menu.php so that it displays prices next to the courses.

 

So basically I need to print out a menu, that displays the day, then under that, the menu for that day as well as how much each order costs.

I am really confused working with more then 2 arrays in one. Can anyone please help in doing this.

 

 

Thank you very much.

Link to comment
https://forums.phpfreaks.com/topic/69039-solved-help-with-modifying-an-array/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.