PHP array_push() 函数
PHP 教程
· 2019-01-22 11:58:26
实例
向数组尾部插入 "blue" 和 "yellow":
<?php
$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);
?>
$a=array("red","green");
array_push($a,"blue","yellow");
print_r($a);
?>
定义和用法
array_push() 函数向数组尾部插入一个或多个元素。
提示:您可以添加一个或者多个值。
注释:即使您的数组有字符串键名,您所添加的元素将是数字键名(参见下面的实例)。
语法
array_push(array,value1,value2...)
| 参数 | 描述 |
|---|---|
| array | 必需。规定一个数组。 |
| value1 | 必需。规定要添加的值。 |
| value2 | 可选。规定要添加的值。 |
技术细节
| 返回值: | 返回新数组的元素个数。 |
|---|---|
| PHP 版本: | 4+ |
更多实例
实例 1
带有字符串键名的数组:
<?php
$a=array("a"=>"red","b"=>"green");
array_push($a,"blue","yellow");
print_r($a);
?>
$a=array("a"=>"red","b"=>"green");
array_push($a,"blue","yellow");
print_r($a);
?>
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
Cypherpunks
Julian Assange、Jacob Appelbaum、Andy Müller-Maguhn、Jérémie Zimmermann / OR Books / 2012-11 / GBP 8.99
Cypherpunks are activists who advocate the widespread use of strong cryptography (writing in code) as a route to progressive change. Julian Assange, the editor-in-chief of and visionary behind WikiLea......一起来看看 《Cypherpunks》 这本书的介绍吧!