Jump to content

Array question


SmokingMan

Recommended Posts

I want to teach myself to write a page at load from an array. That way all the would need to be changed would be the array entries. This would probably be better using an SQL database, but I want to learn this way first. I thought it would be a good excercise.What I want to write is a menu with the item, description, and price. I'm trying to figure out the best way to set up an array with this information. The best way I seem to be able to figure this out right now would be this:

		   <?php			$menu = array			(			 "first_item"=>array			   "first_item",			   "first_item_description",			   "first_item_price"			   ),			  "second_item"=>array			   (			   "second_item",			   "second_item_description",			   "second_item_price"			   ),			);			?>

...and so on.Is this the best way to write a multi-dimensional array, or is there a better way? If my thinking is right, and that's always subject to interpretation :) , I would use a loop to go through each array using "echo" statements to write the code for each menu item. I know there's probably a better way to do this, but right now I want to learn how to do this using the data from an array. This is just an excercise, hopefully not in futility :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...