From:             shrub at yahoo dot com
Operating system: n/a
PHP version:      5.1.0RC1
PHP Bug Type:     Feature/Change Request
Bug description:  would like an array_key_value_pop function

Description:
------------
When you call array_pop on an array, you only get back the 
value. It would be nice if there was an array_key_value_pop 
function that returned both the key and the value.

Reproduce code:
---------------
function array_key_value_pop (&$a) {
    end($a);
    $lastItem = each($a);
    array_pop($a);

    return array($lastItem["key"] => $lastItem["value"]);
}



Expected result:
----------------
$a = array ("red"=>"12a", "fish" => "rock", "blue" => "xyz");
print_r (array_key_value_pop($a));

Array
(
    [blue] => xyz
)

print_r($a);

Array
(
    [red] => 12a
    [fish] => rock
)


Actual result:
--------------
n/a

-- 
Edit bug report at http://bugs.php.net/?id=34506&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34506&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34506&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34506&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34506&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34506&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34506&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34506&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34506&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34506&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34506&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34506&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34506&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34506&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34506&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34506&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34506&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34506&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34506&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34506&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34506&r=mysqlcfg

Reply via email to