search
HomeBackend DevelopmentPHP ProblemLearn more about PHP arrays! ! !

Learn more about PHP arrays! ! !

May 27, 2021 pm 04:31 PM
phparray

The previous article introduced you to "How to process PHP forms? If it were you, how would you handle it? 》, this article continues to introduce PHP multi-dimensional arrays to you. I believe many friends have some confusion about arrays. What are you waiting for? Let’s go together! ! !

Learn more about PHP arrays! ! !

What is PHP multidimensional array:

Multidimensional array, each element consists of a value and multiple elements that can be determined The position is composed of subscripts. According to the description of the order relationship of multiple subscript changes in the array, the predecessor and successor relationships of the array elements can be determined and the corresponding linear table can be written.

Multi-dimensional arrays can also be composed of elements (n 1) It is defined by a special linear table of dimensional arrays, so that multi-dimensional arrays with dimensions greater than one are synthesized by the linear table structure, which is a generalization of linear tables.

As shown in the picture below:

Learn more about PHP arrays! ! !

Regarding PHP multi-dimensional arrays, we take the specific code as an example:

<?php
// 二维数组:
$cars = array
(
    array("YSL",200,90),
    array("TF",80,59),
    array("cpb",350,100)
);
print_r($cars); 
?>

The running results are as follows Display:

Learn more about PHP arrays! ! !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.

The code is shown as follows:

<?php 
$sites = array 
( 
    "php"=>array 
    ( 
        "php中文网", 
        "http://www.php.cn" 
    ), 
    "google"=>array 
    ( 
        "拼多多", 
        "http://www.pingduoduo.com" 
    ), 
    "taobao"=>array 
    ( 
        "京东", 
        "http://www.jingdong.com" 
    ) 
); 
print("<pre class="brush:php;toolbar:false">"); // 格式化输出数组 
print_r($sites); 
print("
");  ?>

The running results are as follows:

Learn more about PHP arrays! ! !

Recommended learning: "PHP Video Tutorial

The above is the detailed content of Learn more about PHP arrays! ! !. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool