The array() function in PHP creates an array.
Array is of three types in PHP.
Indexed arrays − It is an array with numeric index
Associative arrays − It is an array with named keys
Multidimensional arrays − It is an array that have one or more arrays
Syntax
1 2 3 4 |
|
Parameters
value − Set the value.
key − Set the key.
Return
The array() function returns an array of the parameters.
The following is an example of indexed arrays.
Example
Live Demo
1 2 3 4 5 6 7 8 |
|
输出
1 2 3 4 |
|
The following is an example of associative arrays.
Example
Live Demo
1 2 3 4 5 6 7 |
|
输出
1 2 |
|
以上就是PHP中的array()函数的详细内容,更多请关注php中文网其它相关文章!
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。