Name
array_push()
Synopsis
int array_push ( array&arr
, mixedvar
[, mixed ...] )
The array_push()
function takes an array and a new value as its only parameter, and pushes that value onto the end of the array, after all the other elements. This is the opposite of the array_pop()
function:
$firstname = "Johnny"; $names = array("Timmy", "Bobby", "Sam", "Tammy", "Joe"); array_push($names, $firstname); // first is Timmy; last is now Johnny
Get PHP in a Nutshell 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.