array_push() Definition and Usage
The array_push() function adds one or more elements (push) to the end of the array of the first parameter, and then returns the length of the new array.
This function is equivalent to calling $array[] = $value multiple times.
Syntax
array_push(array,value1,value2...) Parameter Description
array Required. Specifies an array.
value1 required. Specifies the value to add.
value2 optional. Specifies the value to add.
Tips and Notes
Note: Even if there are string key names in the array, the elements you add are always numeric keys. (See Example 2)
Note: If you use array_push() to add a unit to the array, it is better to use $array[] =, because there is no additional burden of calling the function.
Note: array_push() will issue a warning if the first argument is not an array. This is different from the behavior of $var[], which creates a new array.
Example 1