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.
$arr is a PHP array and $value1,$value2 and $valueN are values to be added to the end of $arr.
<?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); ?>
You May Also Like
Subscribe To Never Miss an Article From