|
Hi! :D
I tried alot, the only thing, that i got was we can access indexed array using foreach loop but we cannot access associative array using for-loop.
If, in case your using associative multi-dimensional array, then you hav to use for-loop, till to u reach actual associative array and then again use for-each loop. E.g:
$var1=array(array("MH"=>"Maharashtra", "KA"=>"Karnataka"),array("AM"=>"America", "AU"=>"Australia"));
echo "<h4> Using For-Each Loop:</h4>";
for($i=0;$i<count($var1);$i++)
{
foreach($var1[$i] as $key=>$value)
{
echo " ", $value;
}
}
Thanks and regards.
Shital. :)
|