Wednesday, 29 August 2018

How to echo multidimensional array in PHP

I am trying to print multidimensional array in php below is my array and array variable is gplus

 Array ( [0] => Array ( [name] => krishna sitaram [email] => kasyapa25@gmail.com )
            [1] => Array ( [name] => ravi kumar [email] => ravikumar@gmail.com )

i tried bellow
foreach($gplus as $gvalue){
      echo  $gvalue."<br />";
      }

but not working.
the result should be
name               email
krishna sitaram   kasyapa25@gmail.com
ravi kumar        ravikumar@gmail.com

Thank you all i got the the correct solution is
foreach($gplus as $array){
     echo $array['name']."<br />";
     echo $array['email']."<br />";

}


If you're just debugging:
print_r($your_associative_array);

If you want to print it:
foreach($gplus as $array){
    foreach($array as $key=>$value){
      echo "Key: $key / Value: $value<br />";
    }
}

0 comments:

Post a Comment