+ 1

I have a question in PHP. In two-dimension array, how to declare an array by assigning both numeric in row and column anddisplay

Multi-dimension array in PHP

12th May 2019, 3:24 PM
Avijit Bakshi
Avijit Bakshi - avatar
3 Respuestas
+ 5
Avijit Bakshi Like in most programming language, a multidimensional array in PHP is an array that consists of another array. Take a look at the following snippet and in case you have a question, feel free to ask. <?php $matrix = array( array(1,2,3,4,5), array(6,7,8,9,10), array(11,12,13,14,15), array(16,17,18,19,20), array(21,22,23,24,25) ); // foreach - Reference // http://php.net/manual/en/control-structures.foreach.php // Iterate the array rows foreach($matrix as $row) // for each row in matrix { // Iterate the array columns foreach($row as $column) // for each column in row { echo $column . ' '; } // Insert line break after each row echo '<br />'; } ?>
14th May 2019, 3:38 PM
Ipang
+ 2
I can't visualize your idea, can you give a sample desired result?
12th May 2019, 7:10 PM
Ipang
+ 2
Like an example of matrix and display the elements in php
14th May 2019, 2:03 PM
Avijit Bakshi
Avijit Bakshi - avatar