Easy Tutorial
❮ Func Array Uksort Func Filesystem File ❯

PHP array_push() Function

Complete PHP Array Reference Manual

Example

Insert "blue" and "yellow" at the end of the array:


Definition and Usage

The array_push() function inserts one or more elements to the end of an array.

Tip: You can add one or multiple values.

Note: Even if your array has string keys, the added elements will have numeric keys (see example below).


Syntax

Parameter Description
array Required. Specifies an array.
value1 Required. Specifies the value to add.
value2 Optional. Specifies the value to add.

Technical Details

Return Value: Returns the new number of elements in the array.
PHP Version: 4+
--- ---

More Examples

Example 1

Array with string keys:

❮ Func Array Uksort Func Filesystem File ❯