array_push() function in php
0 2648
array_push() function of PHP is used to insert one or more item to the end of an array. It is an inbuilt function of PHP.
Syntax:
array_push($arr,$value1,$value2,.....,$valueN);
Here
$arr is a PHP array and $value1,$value2 and $valueN are values to be added to the end of $arr.
Example:
<?php $arr1 = array("fruit1"=>"apple","fruit2"=>"banana","fruit3"=>"orange"); echo "<pre>"; echo "Before apply array_push() function <br>"; print_r($arr1); array_push($arr1,"grape","pear"); echo "<br> After apply array_push() function"; print_r($arr1); ?>
Output:

Share:
Comments
Waiting for your comments