PHP multidimensional array
The value in one array can be another array, and the value of another array can also be an array. In this way, we can create two-dimensional or three-dimensional arrays:
<?php // Two-dimensional array:
$cars = array
PHP - Multidimensional array
A multidimensional array is an array of one or more arrays.
In a multidimensional array, each element in the main array can also be an array, and each element in the subarray can also be an array.
In this example, we created a multidimensional array that automatically assigns ID keys:
$sites = array
"php Chinese network",
Print(""); // format the output array
Let's try to display a value in the above array:
Echo $sites['php'] . 'Address is:' . $sites['php'];
The above code will output:
A multidimensional array refers to an array containing one or more arrays.
1. There are no other arrays in the one-dimensional array array, only some variables or values.
2. Insert a single layer of an array into a two-dimensional array array, or multiple arrays
3. The three-dimensional array inserts an array (B) into the array (A), and inserts a level array (C) into the B array. This is called a three-dimensional array.
4. More than three-dimensional, all are called multi-dimensional arrays.
Difficulties in learning multidimensional arrays:
Pay attention to the format, and align the line breaks and indents of each dimension. It is not easy to make mistakes.
The separator between array elements is a comma. When inserting an array into an array, do not write a semicolon (;) at the end.