| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2010-07-24 17:40 UTC] dtajchreber@php.net
 
-Status: Open
+Status: Wont fix
  [2010-07-24 17:40 UTC] dtajchreber@php.net
  | 
    |||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 13:00:02 2025 UTC | 
Description: ------------ Description: It would be nice if functions array_pop and array_shift took a parameter that told how many elements to pop. Example: mixed array_pop ( array &$array , $num = 1 ) mixed array_shift ( array &$array , $num = 1 ) Test script: --------------- function array_pop_mine(array &$array, $num) { $removed = array(); while ($num > 0) { //$removed[] = array_pop($array); array_unshift($removed, array_pop($array)); --$num; } //return array_reverse($removed); return $removed; } $arr = array(3, 1, 4, 1, 5, 9); print_r($arr); $rem = array_pop_mine($arr, 3); print_r($arr); print_r($rem); Actual result: -------------- Array ( [0] => 3 [1] => 1 [2] => 4 [3] => 1 [4] => 5 [5] => 9 ) Array ( [0] => 3 [1] => 1 [2] => 4 ) Array ( [0] => 1 [1] => 5 [2] => 9 )