Definition and usage
Array () creates arrays with keys and values. If the key is omitted when the array is created, an integer key is generated, starting from 0 by default and incrementing by 1.
Create an array with array () and use the = = to separate the keys and values.
To create an empty array, the parameter is not passed to array ():
$new = Array ();
Note: Array () is actually a language structure (language construct), which is typically used to define a direct array, but its usage is very similar to that of a function, so we'll also list it in the manual.
Grammar:
| Parameters |
Describe |
| Key |
Optional. The specified key, type is numeric or string. If not set, the key of the integer type is generated. |
| Value |
Necessary. Specified value. |
Example 1
Output:
Array ( [A] = AA [b] = BB [c] = CC)
Example 2
Output:
Array ( [0] = AA [1] = BB [2] = CC)
PHP Arrays Array ()