+ 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
3 Réponses
+ 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 />';
}
?>
+ 2
I can't visualize your idea, can you give a sample desired result?
+ 2
Like an example of matrix and display the elements in php