array_push

int array_push(array array, mixed vars, mixed ...) 
array Array to which to add the new value(s)
vars Value to append to array
... Further values to add

Appends the list of mixed variables onto the given array.

Returns:

Number of elements appended to the array; NULL on failure

Description:

This function appends one or more values to the array given by array . All values beyond the first are appended. Any type of variable can be appended, including mixed or multidimensional arrays. New elements will always have incrementally-increased numeric keys in array , and the new elements will be added in the order in which they are passed to array_push().

This function can be used with array_pop() to treat arrays as stacks.

Warning:

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.