array()

Creates an array. PHP arrays can hold any type, be indexed or associative, and grow dynamically.

Syntax

php
array(value1, value2, ...)
[value1, value2, ...]

Example

php
$fruits = ["apple", "banana", "cherry"];
$person = ["name" => "Alice", "age" => 28];
$matrix = [[1, 2], [3, 4]];
echo $fruits[0];        // apple
echo $person["name"];   // Alice