Insert "blue" and "yellow" to the end of an array:
The array_push() function inserts one or more elements to the end of an array.
Tip: You can add one value, or as many as you like.
Note: Even if your array has string keys, your added elements will always have numeric keys (See example below).
Parameter | Description |
---|---|
array | Required. Specifies an array |
value1 | Required. Specifies the value to add |
value2 | Optional. Specifies the value to add |
Return Value: | Returns the new number of elements in the array |
---|---|
PHP Version: | 4+ |
An array with string keys: