本文介绍下,php数组操作之在数组尾添加元素的方法,有需要的朋友参考下。
在数组尾添加元素,用到php数组操作函数array_push。 array_push()函数 返回值是int型,是压入数据后数组中元素的个数,可以为此函数传递多个变量作为参数,同时向数组压入多个变量。 其形式为: (array array,mixed variable [,mixed variable...]) 例子,在$fruits数组中又添加了两个水果: @@######@@ |
<?php //在数组尾添加元素 $fruits = array("apple","banana"); array_push($fruits,"orange","pear") //$fruits = array("apple","banana","orange","pear") ?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号