Parsing the array_push() function in PHP

autoload
Release: 2023-03-09 13:04:02
Original
2271 people have browsed it

<img src="https://img.php.cn/upload/image/295/487/834/1620268826339661.jpg" title="1620268826339661.jpg" alt="Parsing the array_push() function in PHP">

phpWe often need to operate on arrays. Sometimes we may need to add units into the array,phpThe 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 $... = ?  )
Copy after login
  • $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);
?>
Copy after login
输出:5
     Array ( [a] => A张三 [c] => b李四 [b] => a王五 [0] => 陆六 [1] => 金七 )
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!