array / [ ]
Creates a collection of values.
Syntax
$name = [e1, e2, ...];
Description
Arrays are created using square brackets. Elements are accessed with 0-based indexing.
Example
Loading editor…
Expected output
red 3
When to use?
Holding lists (names, products).
Common mistakes
- ⚠️ Indexing starts at 0: the first element is $arr[0].