Hello Friend how are you i hope you all are doing well. Today in this post we will learn about Multidimensional Array in PHP like what is Multidimensional Array, Syntax of Multidimensional Array, Initialization of Multidimensional Array with examples. If you want to learn PHP in very simple easy way then this post will help you definitely.
Multidimensional Array in PHP
1.The array inside array is called multidimensional array.
2.When an array contains one or more array then it is called Multidimensional array.
3.array() function is used to create array in PHP.
<?php $matrix=array(array(80,50,20),array(70,40,10),array(90,60,30)); for($i=0;$i<=2;$i++) { for($j=0;$j<=2;$j++) { echo $matrix[$i][$j]." "; } echo "<br>"; } /* OUTPUT 80 50 20 70 40 10 90 60 30 */ ?>
<?php $student=array( "Rocky"=>array( "rollno"=>"205", "branch"=>"Computer science" ), "Raj"=>array( "rollno"=>"209", "branch"=>"Information technology" ), "Tony"=>array( "rollno"=>"206", "branch"=>"Civil Engineering" ) ); /* Printing Rocky information */ echo $student['Rocky']['rollno']."<br>"; echo $student['Rocky']['branch']."<br>"; /* Printing Tony information */ echo $student['Tony']['rollno']."<br>"; echo $student['Tony']['branch']."<br>"; /* OUTPUT 205 Computer science 206 Civil Engineering */
1.Indexed Array Click here to learn.
2.Associative Array Click here to learn.
3.Multi Dimension Array Click here to learn.
Request:-If you found this post helpful then let me know by your comment and share it with your friend.
0 Comments