Home  >  Article  >  Backend Development  >  Types of PHP arrays - multidimensional arrays

Types of PHP arrays - multidimensional arrays

黄舟
黄舟Original
2017-05-04 10:04:264222browse

Types of PHP arrays - multidimensional arrays

What is a PHP multidimensional array?

The two articles introduced earlier "Types of PHP arrays-numeric index array" and "Types of PHP arrays-associative arrays" They are all one-dimensional arrays. Today we will introduce multi-dimensional arrays in detail!

Arrays with more than one dimension can be called multi-dimensional arrays

We need to understand that an array is not necessarily a simple list of subscripts and values. In fact, each element in the array The elements can also be another array.

So if the array element in a one-dimensional array is also an array, then it becomes a two-dimensional array.

PHP multi-dimensional array sample code

##Dimensions of the array: two-dimensional

Types of PHP arrays - multidimensional arrays

Define the above two-dimensional array:

The way to obtain the element "Li Qiang" in the above two-dimensional array is as follows:

The output result is :

Types of PHP arrays - multidimensional arrays

Types of PHP arrays - multidimensional arrays

##Dimensions of the array: three-dimensional

Types of PHP arrays - multidimensional arraysMethod to obtain "Li Qiang" and "Liu Jun":

";
echo $arr[1][1][1];//获取刘军的方式
?>

The output result is:

Types of PHP arrays - multidimensional arrays


【Related tutorial recommendations】

    Related topic recommendations: "
  1. php array (Array)"

The above is the detailed content of Types of PHP arrays - multidimensional arrays. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn