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

Master the array array in PHP (with code analysis)

autoload
autoloadOriginal
2021-05-06 11:32:402854browse

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);
输出:Array ( [0] => 12 [1] => 213 [2] => 324 [3] => 454 [4] => 5 [5] => 565 [6] => 768 [7] => 前方 )

2.Associative array

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

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!

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