array_push_PHP array_push()函数与示例
array_push
PHP array_push()函数 (PHP array_push() function)
array_push() function is used to insert/push one or more than one element to the array.
array_push()函数用于将一个或多个元素插入/推入数组。
Syntax:
句法:
array_push(array, elemement1, [element2],..);
Here,
这里,
array is the source array in which we have to push the elements.
array是我们必须在其中推送元素的源数组。
element is the value to be added, we can add more than one elements too.
element是要添加的值,我们也可以添加多个元素。
Examples:
例子:
Input:
//initial array is
$arr = array(100, 200, 300);
//pushing elements
array_push($arr, 10);
array_push($arr, 400, 500);
Output:
Array
(
[0] => 100
[1] => 200
[2] => 300
[3] => 10
[4] => 400
[5] => 500
)
PHP code 1: Inserting elements in an indexed array
PHP代码1:在索引数组中插入元素
<?php
$arr = array(100, 200, 300);
array_push($arr, 10);
array_push($arr, 400, 500);
print("array after inserting elements...\n");
print_r($arr);
?>
Output
输出量
random key: age
array of random keys...
Array
(
[0] => age
[1] => city
)
PHP code 2: Inserting elements in an associative array
PHP代码2:在关联数组中插入元素
<?php
$arr = array("name" => "Amit", "age" => 21);
array_push($arr, "Gwalior");
array_push($arr, "Male", "RGTU University");
print("array after inserting elements...\n");
print_r($arr);
?>
Output
输出量
array after inserting elements...
Array
(
[name] => Amit
[age] => 21
[0] => Gwalior
[1] => Male
[2] => RGTU University
)
See the output – There are two keys name and age and we added three more elements "Gwalior", "Male" and "RGTU University", these three elements added with the keys 0, 1 and 2.
看到输出-有两个关键的姓名和年龄 ,我们增加了三个要素“瓜廖尔”,“ 男性”和“RGTU大学”,与键0,1和2添加了这三个要素。
翻译自: https://www.includehelp.com/php/array_push-function-with-example.aspx
array_push
array_push_PHP array_push()函数与示例相关推荐
- php中push数组,php中的array_push函数怎么用
php中的array_push函数的用法:[array_push(array,value1)].array_push函数用于向指定数组的尾部添加一个或多个元素,并返回新数组的长度. php array ...
- php编程里的push,【编程词典】php array_push()函数
英 [pʊʃ] 美 [pʊʃ] vt.& vi.推,推动 vt.按;推动,增加;对-施加压力,逼迫;说服 n.推,决心;大规模攻势;矢志的追求 vi.推进;增加;努力争取 第三人称单数: ...
- php指定长度 分割整形,php指定长度分割字符串str_split函数用法示例
本文实例讲述了php指定长度分割字符串str_split函数用法.分享给大家供大家参考,具体如下: 示例1:$str = 'abcdefgh'; $arr = str_split($str,2); 运 ...
- getdate函数_PHP getdate()函数与示例
getdate函数 PHP getdate()函数 (PHP getdate() function) getdate() function is used to get the local date/ ...
- 安卓log.e函数打印示例_log1p()函数以及C ++中的示例
安卓log.e函数打印示例 C ++ log1p()函数 (C++ log1p() function) log1p() function is a library function of cmath ...
- php里push的用法,php array_push函数怎么用?
php array_push函数用于向数组尾部插入一个或多个元素,其语法是array_push(array,value1,value2...),参数array必需,指规定一个数组:value1必需,指 ...
- gettimeofday_PHP gettimeofday()函数与示例
gettimeofday PHP gettimeofday()函数 (PHP gettimeofday() function) gettimeofday() function is used to g ...
- dir函数_PHP dir()函数与示例
dir函数 PHP dir()函数 (PHP dir() function) dir() function is an instance of the directory class, it is u ...
- PHP rewinddir()函数与示例
PHP rewinddir()函数 (PHP rewinddir() function) rewinddir() function is used to rewind/reset the direct ...
最新文章
- 基于协同过滤算法实现选课推荐系统
- 【转】【Centos】Centos下用upstart管理自己的服务程序
- [Linux] linux下安装配置 zookeeper/redis/solr/tomcat/IK分词器 详细实例.
- 【数据库】navicat运行sql文件报错
- 使用计算机的好处作文,电脑的好处
- python动态图片转字符画_【小工具】使用python将图片转彩色字符画
- 扩展卡尔曼滤波算法——基本原理及举例(python实现radar数据滤波)
- 日本经验 | 距离最新潮的老年电竞,中国还有多远?
- 微信转账2020假图片_微信头像图片2020独一无二
- MDI和MDIX模式配置linux,当交换机不支持MDI/MDIX时,交换机(无级连端口)间级连采用的线缆为...
- 《Network Science》:一本关于网络科学的书
- LINUX基础知识笔记全
- ps因计算机限制打不开,电脑突然坏了只有打不开PS这是什么原因在线 – 手机爱问...
- Jstate JVM分析
- android自动切换图片,Android应用中图片浏览时实现自动切换功能的方法详解
- java的高内聚和低耦合_彻底弄懂高内聚与低耦合
- 【转】聊聊Greenplum的那些事
- [转载] 晓说——第11期:揭秘我党历史上最危险的叛徒
- linux点阵数字图案,新人求助 点阵识别 数字
- 2015优秀邮件营销人员自我修炼指南
热门文章
- Windows安全配置加固
- 五猴分桃c语言课程设计,c语言程序设计五猴分桃问题实验报告.doc
- html5 多页面共享数据库,可以跨页面使用HTML5 Web SQL数据库吗?(Can HTML5 Web SQL databases be used across pages?)...
- jquery css事件编程 尺寸设置
- [vue插件]基于vue2.x的电商图片放大镜插件
- 一张图一个表——CSS选择器总结
- Python的看门狗实现自动化实时对服务器、Windows或Linux文件夹的实时监控
- 2018-04-22接口自动化测试学习心得(1)
- iOS正则表达式(亲测,持续更新)
- 我的osu游戏程序设计(oo)