Concept
How does PHP support and create multidimensional arrays?
ComputerScienceOne / Multidimensional Arrays
"PHP supports multidimensional arrays in the sense that elements in an array can be of any type, including other arrays. We can use the same syntax and operations for single dimensional arrays. For example, we can use the double arrow syntax and assign arrays as values to create a 2-dimensional array.\n\n$mat = array(\n\n0 => array(10, 20, 30),\n\n1 => array(40, 50, 60),\n\n2 => array(70, 80, 90)\n\n);\n\nprint_r($mat);\n\nWhich results in the following:\n\nArray (\n\n[0] => Array ( [0] => 10 [1] => 20 [2] => 30 )\n\n[1] => Array ( [0] => 40 [1] => 50 [2] => 60 )\n\n[2] => Array ( [0] => 70 [1] => 80 [2] => 90 )\n\n)"
Related Ideas
- How do you create and index arrays in PHP?ComputerScienceOne · Creating Arrays
- How are arrays passed to methods in Java?ComputerScienceOne · Multidimensional Arrays
- How do you declare and allocate a two-dimensional array in Java?ComputerScienceOne · Multidimensional Arrays
- What section covers dynamic data structures?ComputerScienceOne · Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . .
- How can you iterate over indexed and associative arrays in PHP?ComputerScienceOne · Iteration