Home Tutorial Php Phparray PHP Array push

 
 

Share on Google+Share on Google+
PHP Array push
Posted on: October 28, 2009 at 12:00 AM
Advertisement
This section demonstrates the use of array_push function in php

  • Element in the array is pushed or added at its end.
  • This is done by the function array_push().
  • array_push function adds Single or multiple elements


PHP Array Push Function Example

<?php
    $arr1
=array(1,2,3,4,5);
    foreach
($arr1 as $ar) {
      echo
" ".$ar;
     }
 
    echo
"<br>after pushing elements <br>";
    array_push($arr1,12,19);

    foreach
($arr1 as $ar1){
     echo
" ".$ar1;
     }
?>

Output
1 2 3 4 5
after pushing elements
1 2 3 4 5 12 19

 

Advertisement

Related Tags for PHP Array push:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 28, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com