How to write two-dimensional array in php

藏色散人
Release: 2023-02-26 19:58:02
Original
5318 people have browsed it

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)
);
?>
Copy after login

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
        )

)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!