array_push
Pushes one or more elements onto the end of an array and returns the new number of elements.
Parameters
main.php
Return Values
int
Returns the new number of elements in the array
On success:Number of elements after adding new values
On failure:Warning if first argument is not an array
Notes
- Modifies the original array by reference
- For adding single elements, $array[] = $value is more efficient
- New elements get numeric keys even if array has string keys
- Can add multiple values in a single call
Changelog
- 7.3.0: Function can now be called with only one parameter
Related Functions
array_filter
ArrayFilters elements of an array using a callback function, returning only elements that pass the test.
filtercallbackarray