How to create multidimensional array in php dynamically

How to declare and display two dimension array in php with their values on screen using echo method.

Multidimensional array means a array which contain more then two array inside a single array and they both can be accessible through single array so you don’t need to declare multiple standalone arrays. A single array can hole two, three, four array inside single array. So in this tutorial we are creating two dimensional array and after that printing each array element on screen using echo method. So here is the complete step by step tutorial for How to create multidimensional array in php dynamically.

android-project-download-code-button

How to create multidimensional array in php dynamically.

Code for multidimensional-array.php file.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>How to create multidimensional array in php dynamically</title>
</head>

<body>

<?php

//declaring two dimensional array.
$subjects = array(
array("Android","Android Studio"),
array("Php","Dreamwear"),
array("Java","Eclipse"),
array("Html","Notepad"),
);


// Printing array values on screen.

 echo "Code Editor For " . $subjects[0][0]. ' is ' . $subjects[0][1] . '</br>';
 echo "Code Editor For " . $subjects[1][0]. ' is ' . $subjects[1][1] . '</br>';
 echo "Code Editor For " . $subjects[2][0]. ' is ' . $subjects[2][1] . '</br>';
 echo "Code Editor For " . $subjects[3][0]. ' is ' . $subjects[3][1] . '</br>';

?>
</body>
</html>

Screenshot:

How to create multidimensional array in php dynamically

Click here to download How to create multidimensional array in php dynamically project file with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *