Home Tutorial Php Phparray PHP Array Pop

 
 

Share on Google+Share on Google+
PHP Array Pop
Posted on: October 29, 2009 at 12:00 AM
Advertisement
This section demonstrates the use of the array_pop function in the PHP

  • last element of the array is popped by the PHP array_pop() function.
  • array_pop() function in PHP makes the given array with one element lesser
  • It pops up (deletes) the last element  and return it.


PHP Array POP Example
  • <?php
        $arr2
    =array(22,33,44,55,10,80,8);
        echo
    "array values are<br>";

        foreach
    ($arr2 as $a)
          echo
    " ".$a;
        $pop
    =array_pop($arr2);

        echo"<br>pop out element is ".$pop;
        echo
    "<br>array values after popping are <br>";
        foreach
    ($arr2 as $a)
          echo
    " ".$a;
    ?>

              Output
        array values are
        22 33 44 55 10 80 8
        pop out element is 8
        array values after popping are
        22 33 44 55 10 80

Advertisement

Related Tags for PHP Array Pop :


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 29, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com