From: wgilk at reliablesites dot com
Operating system: ALL
PHP version: 6CVS-2007-01-11 (CVS)
PHP Bug Type: Feature/Change Request
Bug description: Please add an array_remove function
Description:
------------
It would be very nice to have an array_remove (or some other
name) function to do what the code below illustrates.
The point of the function is to allow use to retrieve the
value of a particular key in an array, and remove it from the
array at the same time. Think of it as array_shift(), but with
the ability to define the key that gets shifted.
Reproduce code:
---------------
function array_remove ($key, &$array) {
if (! isset ($array[$key])) return false;
$return = $array[$key];
unset ($array[$key]);
return $return;
}
$array = array ('food' => 'taco', 'drink' => 'juice');
$value = array_remove ('food', $array);
print_r ($array);
print $value;
Expected result:
----------------
FROM print_r:
----
array (
'drink' => 'juice
)
----
FROM print:
----
taco
----
--
Edit bug report at http://bugs.php.net/?id=40101&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=40101&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=40101&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=40101&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40101&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=40101&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40101&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40101&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40101&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40101&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40101&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=40101&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=40101&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40101&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40101&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40101&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40101&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40101&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40101&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40101&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40101&r=mysqlcfg