array_push in PHP

Syntax of array_push

int array_push(array &array, mixed value1[, … mixed valueN])

Adds the given values to the end of the array specified in the first argument and returns the new size of the array. Performs the same function as calling $array[] = $value for each of the values in the list

Example of array_push

$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
    [0] => orange
    [1] => banana
    [2] => apple
    [3] => raspberry

Leave a Comment