← All built-ins / array_push()

array_push()

array_push(...$args): int

Parameters

NameTypeDescription
$aarrayarray (by reference)
$...mixedvalues to append

Return value

New element count. $arr[] = v does the same for one value.

Example

$a = [1];
$n = array_push($a, 2, 3);
echo $n, " ", implode(",", $a);
3 1,2,3

See also

array_pop()array_unshift()