Home > Backend Development > PHP Problem > Master the array array in PHP (with code analysis)

Master the array array in PHP (with code analysis)

autoload
Release: 2023-03-09 13:08:02
Original
2862 people have browsed it

Master the array array in PHP (with code analysis)

Array is a collection of data in php. It can store multiple values ​​​​in a single variable. Arrays are often operated on in php. This article will take you through it. Take a look at the array array in php.

Arrays are divided into index array and associative array.

##1 .Index array

<?php
$arr1=[12,213,324,454,5,565,768,"前方"];
print_r($arr1);
Copy after login
输出:Array ( [0] => 12 [1] => 213 [2] => 324 [3] => 454 [4] => 5 [5] => 565 [6] => 768 [7] => 前方 )
Copy after login

2.Associative array

<?php
$arr2=array("first"=>"张三","second"=>"王五","将来");
print_r($arr2);
Copy after login
输出:Array ( [first] => 张三 [second] => 王五 [0] => 将来 )
Copy after login

Recommended: 2021 PHP interview questions summary (collection)》《php video tutorial

The above is the detailed content of Master the array array in PHP (with code analysis). 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