国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Multidimensional Arrays

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 a two-dimensional or three-dimensional array:

Example

<?php
 // 二維數(shù)組:
 $cars = array
 (
     array("Volvo",100,96),
     array("BMW",60,59),
     array("Toyota",110,100)
 );
 ?>

PHP - Multidimensional Array

A multidimensional array contains a or Array of multiple 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.

Example

In this example, we create a multi-dimensional array with automatically assigned ID keys:

Example

<?php 
 $sites = array 
 ( 
     "php"=>array 
     ( 
         "php中文網(wǎng)", 
         "http://miracleart.cn" 
     ), 
     "google"=>array 
     ( 
         "Google 搜索", 
         "http://www.google.com" 
     ), 
     "taobao"=>array 
     ( 
         "淘寶", 
         "http://www.taobao.com" 
     ) 
 ); 
 print("<pre>"); // 格式化輸出數(shù)組 
 print_r($sites); 
 print("</pre>"); 
 ?>

The above array will be output as follows :

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? QQ截圖20161008154229.png

’s ’ :' . $sites['php'][1];

The above code will output:

Multidimensional array

The multidimensional array refers to is an array containing one or more arrays.

1. One-dimensional array There are no other arrays in the array, only some variables or values.

2. A single-layer array or multiple arrays are inserted into a two-dimensional array array

3. A three-dimensional array inserts an array (B) into the array (A), and Another level of array (C) is inserted into the B array, which we call a three-dimensional array

4. Anything with more than three dimensions is called a multi-dimensional array.

Difficulties in learning multi-dimensional arrays:

Pay attention to the format and tidy up the line breaks and indentations of each dimension. It’s not easy to make mistakes.

【Remember】

The separator between array elements is a comma. When inserting an array into an array, do not write a semicolon (;) at the end

Continuing Learning
||
<?php // 二維數(shù)組: $cars = array ( array("Volvo",100,96), array("BMW",60,59), array("Toyota",110,100) ); ?>
submitReset Code