Posted by: Sourav | April 4, 2011

Foreach loop in multidimentional array


<?php
$people[0][0]=”sourav”;
$people[0][1]=”bhattacharya”;
$people[1][0]=”amiya”;
$people[1][1]=”chakraborti”;
$people[2][0]=”swaraj”;
$people[2][1]=”roy”;
$counter1=0;
$counter2=0;
foreach($people as $value1)
{
   
    foreach($value1 as $value2)
    {
        echo “position=$counter1 segment=$counter2 is $value2<br />”;
        $counter2++;
    }
    $counter1++;
}

 ?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: