Array in PHP Part 1
Array in PHP, Array is a container which , contains multiple items in a large container.
Lets explain this by referring to a real life example. You are figuring out a Menu for your restaurant, so you have a Variable category name “$menu”. The Menu you are creating consist of different variety of Foods such as as Burger, Fries , Beer , Coleslaw etc.
The menu is the container, and inside the container there are small boxes which contains all the Food items mentioned above. These small boxes are call arrays. All arrays start from Zero in PHP programming language. You can either call out every single array in the “$menu” Variable or loop through every single Array using the ” Foreach ” Function
Array sequence in Variable
$menu[0] This Array contains the Food " Burger" $menu[1] This Array Contains the Food "Fries " $menu[2] This Array contains the Food " Beer" and so on
Looping through all Array in a Variable using ” Foreach “
<?php $menu = array("Burger","Fries","Beer","coleslaw"); foreach ($menu as $food){ echo $food.'<BR>'; } ?>
Dumping Value in Array
var_dump($food);
Check out PHP For Loop here