Home > Article > Backend Development > Parsing the array_push() function in PHP
<img src="https://img.php.cn/upload/image/295/487/834/1620268826339661.jpg" title="1620268826339661.jpg" alt="Parsing the array_push() function in PHP">
php
We often need to operate on arrays. Sometimes we may need to add units into the array,php
The array_push()
function is built into it, which can push one or more units to the end of the array (on the stack). This article will take you to take a look at it, and first understand the syntax.
array_push ( array $array , mixed $value1 , mixed $... = ? )
$array: Input array.
$value1,...: To push the end value of array.
Return value: Returns the number of elements in the array after processing.
Code example:
<?php $arr=array("a"=>"A张三","c"=>"b李四","b"=>"a王五"); $num=array_push($arr,"陆六","金七"); echo $num,"<br>"; print_r($arr); ?>
输出:5 Array ( [a] => A张三 [c] => b李四 [b] => a王五 [0] => 陆六 [1] => 金七 )
Recommendation: 《2021 PHP Interview Questions Summary (Collection) 》《php video tutorial》
The above is the detailed content of Parsing the array_push() function in PHP. For more information, please follow other related articles on the PHP Chinese website!