Home > Backend Development > PHP Tutorial > PHP array() array

PHP array() array

巴扎黑
Release: 2016-11-22 16:54:52
Original
1228 people have browsed it

array() creates an array, with keys and values. If the key is omitted when specifying the array, an integer key is generated that starts at 0 and increments by 1. To create an associative array with array(), use => to separate the keys and values.

To create an empty array, do not pass parameters to

array(): ​

$new = array();

Note: array()

is actually a language construct, usually It is used to define a direct array, but its usage is very similar to that of functions, so we also list it in the manual

PHP array() example

<span style="font-size: small;">array() 声明数组
<?php
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
print_r($a);
?> 
输出:
Array ( [a] => Dog [b] => Cat [c] => Horse )
</span>
Copy after login


Related labels:
php
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