The previous article introduced you to "How to process PHP forms? If it were you, how would you handle it? 》, this article continues to introduce PHP multi-dimensional arrays to you. I believe many friends have some confusion about arrays. What are you waiting for? Let’s go together! ! !
What is PHP multidimensional array:
Multidimensional array, each element consists of a value and multiple elements that can be determined The position is composed of subscripts. According to the description of the order relationship of multiple subscript changes in the array, the predecessor and successor relationships of the array elements can be determined and the corresponding linear table can be written.
Multi-dimensional arrays can also be composed of elements (n 1) It is defined by a special linear table of dimensional arrays, so that multi-dimensional arrays with dimensions greater than one are synthesized by the linear table structure, which is a generalization of linear tables.
As shown in the picture below:
Regarding PHP multi-dimensional arrays, we take the specific code as an example:
<?php // 二维数组: $cars = array ( array("YSL",200,90), array("TF",80,59), array("cpb",350,100) ); print_r($cars); ?>
The running results are as follows Display:
PHP - Multidimensional Array
A multidimensional array is an array that contains one or more arrays.
In a multi-dimensional array, each element in the main array can also be an array, and each element in the sub-array can also be an array.
The code is shown as follows:
<?php $sites = array ( "php"=>array ( "php中文网", "http://www.php.cn" ), "google"=>array ( "拼多多", "http://www.pingduoduo.com" ), "taobao"=>array ( "京东", "http://www.jingdong.com" ) ); print("<pre class="brush:php;toolbar:false">"); // 格式化输出数组 print_r($sites); print("
The running results are as follows:
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of Learn more about PHP arrays! ! !. For more information, please follow other related articles on the PHP Chinese website!