10 Program to demonstrate Multi-Dimensional Array in PHP

Program:

<?php



$person = array(

  array(78,52,89),

  array(7,42,89),

  array(78,55,49)

);



echo $person[0][1];





foreach( $person as $x)

{ 

    foreach($x as $z)

    {

        echo $z."\n";

    }

    echo "<br>";

}



echo "<br> Next Level:";

foreach( $person as $x=>$y)

{

    print_r($y); 

    echo "<br>";

}



echo "<br/>";

print_r($person);

?>


Output:

Multi-Dimensional Array in PHP



Previous
Next Post »