Home Tutorial Php Phparray PHP Array push

 
 

PHP Array push
Posted on: October 28, 2009 at 12:00 AM
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

 

Related Tags for PHP Array push:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.