From: simon at stienen dot name Operating system: PHP version: 5.3.0RC3 PHP Bug Type: Feature/Change Request Bug description: Introduction of a substitute for array_change_key_case which takes a callback.
Description: ------------ While array_change_key_case allows for changing array keys in regards to capitalization, it is very limited in its function. Therefore I request the introduction of a new function (for the sake of the discussion, I'll call it "array_change_keys") that takes an array and a callback and then calls the callback for each key, passing the key as a parameter (possibly also passing the value as another parameter) and replaces the old key with the return value of the function call - under the same constraints as mentioned in http://php.net/array_change_key_case in terms of replacing elements with colliding keys. Signature: array array_change_keys ( array $input, callback $callback ) Reproduce code: --------------- <?php $a = array( 'peter' => 'm, 71', 'paul' => 'm, 72', 'mary' => 'f, 73' ); $b = array_change_keys($a, 'strlen'); Expected result: ---------------- $b === array( 5 => 'm, 71', 4 => 'f, 73' ) ('paul' was overridden by the element 'mary' which resulted in the same key name) -- Edit bug report at http://bugs.php.net/?id=48543&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48543&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48543&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48543&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48543&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48543&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48543&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48543&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48543&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48543&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48543&r=support Expected behavior: http://bugs.php.net/fix.php?id=48543&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48543&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48543&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48543&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48543&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48543&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48543&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48543&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48543&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48543&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48543&r=mysqlcfg