英[p??] 美[p??]
vt.& vi. Push, push
vt. Press; push, increase; exert pressure on, force; persuade
n. Push, determination; large-scale offensive; determined pursuit
vi. Push; increase; strive for
Third person singular: pushes Present participle: pushing Past tense: pushed past Participle: pushed
php array_push() function syntax
Function: Add one or more elements (push) to the end of the array of the first parameter, and then return the length of the new array.
Syntax: array_push(array,value1,value2...)
Parameters:
Parameters | Description |
array | Required. Specifies an array. |
value1 | Required. Specifies the value to add. |
value2 | Optional. Specifies the value to add. |
Note: Even if there are string key names in the array, the elements you add are always numeric keys. If you use array_push() to add a unit to an array, it is better to use $array[] =, because there is no additional burden of calling the function. array_push() will issue a warning if the first argument is not an array. This is different from the behavior of $var[], which creates a new array.
php array_push() function example
<?php $a=array("西門","滅絕"); print_r(array_push($a,"無忌","黃蓉"));//返回新數(shù)組長(zhǎng)度 echo "<br>"; print_r($a);//打印新數(shù)組 ?>
Run instance?
Click the "Run instance" button to view the online instance
Output:
4 Array ( [0] => 西門 [1] => 滅絕 [2] => 無忌 [3] => 黃蓉 )
<?php $a=array("無忌","歐陽克"); print_r(array_push($a,"滅絕"));//返回新數(shù)組長(zhǎng)度 echo "<br>"; print_r($a);//打印新數(shù)組 ?>
Run Instance?
Click the "Run Instance" button to view the online instance
Output:
3 Array ( [0] => 無忌 [1] => 歐陽克 [2] => 滅絕 )