From:             
Operating system: Linux
PHP version:      5.3.3
Package:          Unknown/Other Function
Bug Type:         Feature/Change Request
Bug description:array_shift/array_pop: add parameter that tells how many to 
elements to pop

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

)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52425&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52425&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52425&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52425&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52425&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52425&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52425&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52425&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52425&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52425&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52425&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52425&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52425&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52425&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52425&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52425&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52425&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52425&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52425&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52425&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52425&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52425&r=mysqlcfg

Reply via email to