This section demonstrates the use of foreach loop in the php
This section demonstrates the use of foreach loop in the php
Example of PHP Array Foreach Loop
<?php
$ar1=array("mango","apple","orange","grapes");
foreach ($ar1 as $a)
echo " ".$a;
$ar1=array("m"=>"mango","a"=>"apple","o"=>"orange","g"=>"grapes");
echo"<br>";
foreach ($ar1 as $key=>$val)
echo " ".$key."-->".$val;
?>
Output
mango apple orange grapes
m-->mango a-->apple o-->orange g-->grapes