array_push
Push one or more cells into the end of the array (to stack)
array_push()
function adds one or more elements (stack) to the end of the array of the first parameter, and then returns the length of the new array.
This function is equal to multiple calls $array[] = $value
.
Insert "blue" and "yellow" into the tail of the array:
<?php $a = array ( "red" , "green" ) ; array_push ( $a , "blue" , "yellow" ) ; print_r ( $a ) ; ?>
Try it yourself
Array with string key names:
<?php $a = array ( "a" => "red" , "b" => "green" ) ; array_push ( $a , "blue" , "yellow" ) ; print_r ( $a ) ; ?>
Try it yourself
array_push ( array , value1 , value2 ... )
parameter | describe |
---|---|
array | Required. Specify array. |
value1 | Required. Specifies the value to be added. |
value2 | Optional. Specifies the value to be added. |