PHP array() array

巴扎黑
巴扎黑Original
2016-11-22 16:54:521253browse

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>


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