To add items to an existing array, you can use the bracket []
syntax.
Add an additional item to the fruits array.
$fruits |
To add items to an associative array (or key/value array), use brackets []
for the key and assign the value using the =
operator.
Add a single item to the car array.
$cars |
To add multiple items to an existing array, use the array_push()
function.
Add three items to the fruits array.
$fruits |
To add multiple items to an existing array, you can use the +=
operator.
Add two items to the cars array.
$cars |