Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write the 3D array of php

Shulou Source: shulou.com Published: 2022-06-02 15:22:22 09月30日 Update

This article mainly explains "how to write a three-dimensional array of php". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to write a three-dimensional array of php".

In PHP, the value in one array can be another array, and the value in another array can also be an array. In this way, we can create a three-dimensional array, such as "$a3=array ('a'));".

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What is the three-dimensional array of php?

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 2D or 3D array:

Examples are as follows:

Definition:

1-dimensional array: $a1=array ('a')

2-dimensional array: $a2=array (array ('a')); / / that is, there is still an array in the array

3-dimensional array: $a3=array ('a')

Visit:

Dimension: $A1 [0]; / / fetch element a, same as below

Dimension: $a2 [0] [0]

3D: $a3 [0] [0] [0]

Special attention should be paid to:

$a2 [$A1 [0]] this does not take the elements of a two-dimensional array, but indicates that $a2 is an one-dimensional array, and we want to take the elements in $a2 with the subscript $A1 [0].

Thank you for your reading, the above is the content of "how to write the three-dimensional array of php". After the study of this article, I believe you have a deeper understanding of how to write the three-dimensional array of php, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Array three-dimensional element learning content writing way two-dimensional subscript that is ideas situations articles more environment computer knowledge knowledge points articles systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei macOS vpn Xiaomi