Home >Backend Development >PHP Problem >How to write two-dimensional array in php

How to write two-dimensional array in php

藏色散人
藏色散人Original
2019-10-16 09:57:105411browse

How to write two-dimensional array in php

How to write a two-dimensional array in php?

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-dimensional or three-dimensional arrays:

Recommended related articles:
1.What is a php two-dimensional array? PHP two-dimensional array example Detailed explanation
2.PHP’s corresponding operations on two-dimensional arrays
Related video recommendations:
1.Dugu Jiujian (4) _PHP video tutorial

Example

<?php
// 二维数组:
$cars = array
(
    array("Volvo",100,96),
    array("BMW",60,59),
    array("Toyota",110,100)
);
?>

Output:

Array
(
    [0] => Array
        (
            [0] => Volvo
            [1] => 100
            [2] => 96
        )

    [1] => Array
        (
            [0] => BMW
            [1] => 60
            [2] => 59
        )

    [2] => Array
        (
            [0] => Toyota
            [1] => 110
            [2] => 100
        )

)

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to write two-dimensional array in php. 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