MULTI DIMENSIONAL ARRAY
ARRAY INSIDE ARRAY
< ? Php
$mul=array (‘Health’=>array(“GREEN TEA”,”SALAD”,
‘UnHealth’=>array(“Pizza”,”Burger”));
//Print the whole Array
Print_r($mul);
//Print Individual Array Value
echo $mul[‘Health’][1]; //Print SALAD
? >
FOR EACH
< ? Php
$mul=array (‘Health’=>array(“GREEN TEA”,”SALAD”,
‘UnHealth’=>array(“Pizza”,”Burger”));
foreach($mul as $key=>$value_InnerArray)
{
echo $key.”
”;
foreach($Inner_Value as $Item)
{
echo $Item;
}
}
? >
Here we have used Multidimensional Array…
In 1st For Each $mul is Main Array It will give is value to $Key and $Inner_Value
$Key Contain the value like “Health” “UnHealth”
$Inner_Value is Inner Array
So to Print the Inner_Value Array Variable Value we need to use the NESTING FOR EACH LOOP.
$Item:- Is the Value of Inner_Value Array Variable…
No comments:
Post a Comment