php multidimensional array – Best 3 Ways To Create multidimensional Array in PHP?

Today, We want to share with you php multidimensional array.In this post we will show you php multidimensional associative array, hear for PHP array with keys we will give you demo and example for implement.In this post, we will learn about PHP Multidimensional Arrays with an example.

php multidimensional array

Example 1 : Multidimensional Arrays

<html>
   <body>
      
      <?php
         $members = array( 
            "pihushree" => array (
               "level" => 35,
               "rank" => 30,	
               "point" => 39
            ),
            
            "bhagyashri" => array (
               "level" => 30,
               "rank" => 32,
               "point" => 29
            ),
            
            "dharmishta" => array (
               "level" => 31,
               "rank" => 22,
               "point" => 39
            )
         );
         
         /* Accessing multi-dimensional array values */
         echo "Members for pihushree in level : " ;
         echo $members['pihushree']['level'] . "<br />"; 
         
         echo "Members for bhagyashri in rank : ";
         echo $members['bhagyashri']['rank'] . "<br />"; 
         
         echo "Members for dharmishta in point : " ;
         echo $members['dharmishta']['point'] . "<br />"; 
      ?>
   
   </body>
</html>

Example 2

<!DOCTYPE html>
<html lang="en">
<head>
    <title>PHP Multidimensional Array</title>
</head>
<body>

<?php
// Define nested array
$members = array(
    array(
        "name" => "Virat dave",
        "email" => "[email protected]",
    ),
    array(
        "name" => "Manju Chovatiya",
        "email" => "[email protected]",
    ),
    array(
        "name" => "Hitesh Dhameliya",
        "email" => "[email protected]",
    )
);
// Access nested value
echo "Virat dave's Email-id is: " . $members[0]["email"];
?>

</body>
</html>

Example 3

<?php
$members =array(
"tamil" => array("Tamilrokers", "bolly4u", "Vegamovies"),
"hindi" => array("tamilblasters", "movizawap"),
"english" => array("oh didi du du"),
"gujrati" => array("kina kina shamo")
);
var_dump($members);
?>

I hope you get an idea about php multidimensional array.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.