Query: array_push
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ARRAY_PUSH(3) 1 ARRAY_PUSH(3) array_push - Push one or more elements onto the end of arraySYNOPSISint array_push (array &$array, mixed $value1, [mixed $...])DESCRIPTIONarray_push(3) treats $array as a stack, and pushes the passed variables onto the end of $array. The length of $array increases by the num- ber of variables pushed. Has the same effect as: <?php $array[] = $var; ?> Note If you use array_push(3) to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function. Note array_push(3) will raise a warning if the first argument is not an array. This differs from the $var[] behaviour where a new array is created.PARAMETERSo $array - The input array. o $value1 - The first value to push onto the end of the $array.RETURN VALUESReturns the new number of elements in the array.EXAMPLESExample #1 array_push(3) example <?php $stack = array("orange", "banana"); array_push($stack, "apple", "raspberry"); print_r($stack); ?> The above example will output: Array ( [0] => orange [1] => banana [2] => apple [3] => raspberry )SEE ALSOarray_pop(3), array_shift(3), array_unshift(3). PHP Documentation Group ARRAY_PUSH(3)
Related Man Pages |
---|
key(3) - php |
arsort(3) - php |
array_walk(3) - php |
array_fill(3) - php |
array_unshift(3) - php |
Similar Topics in the Unix Linux Community |
---|
Array length in PERL |
function return array |
Rotate an array |
how to put element of an array to first position. |
Getting contents of line using a selected one as reference |