亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP multidimensional array

The values ??in one array can be another array, and the values ??in another array can also be an array. In this way, we can create two- or three-dimensional arrays:

Example

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


Run Example?

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.

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://ipnx.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 :

Array
(
[php] => http://ipnx.cn
? ? ? ? ? )

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ‐ ‐ [1] ‐ ‐ ‐ ‐ ‐ [1] => http://www.google.com
)
## [TaoBao] = & GT; Array
(
[0] = & GT; Taobao
[1] = & gtp; http ://www.taobao.com
)

)





##Example 2
Let’s Try to display a value in the above array:

echo $sites['php'][0] . 'The address is:' . $sites['php'][1];

The above code will output:

PHP Chinese website address is: http://ipnx.cn

Example 3

<?php
$all = array("fruits" => array("a"=>"orange","b"=>"banana","c"=>"apple"),                                    
         "ages" => array(18, 20, 25)                                  
      );    
    echo $all["fruits"]["c"];   //輸出apple    
     echo $all["ages"][0];       //輸出18
?>

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