Req #52917 [NEW]: Function to change case-key recursively

From: Date: Thu, 23 Sep 2010 18:53:42 +0000
Subject: Req #52917 [NEW]: Function to change case-key recursively
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154594@lists.php.net to get a copy of this message
From: Operating system: Any PHP version: 5.3.3 Package: Unknown/Other Function Bug Type: Feature/Change Request Bug description:Function to change case-key recursively Description: ------------ Hi, I suggest to create in the next php versions a function similar to array_change_key_case() but doing it recursevely. Bellow I put some example to doing that and the results. regards, Luis Test script: --------------- <?php function arrKey2Lower(&$arrVals) { foreach( $arrVals as $key => $item ) { $key2 = strtolower($key); if ( $key2 != $key) { unset($arrVals[$key]); $arrVals[$key2]=$item; $key=$key2; } if ( is_array($item) ) { arrKey2Lower($arrValores[$key]); } } } $arr = array('ID' => 1, 'NAME'=> 'Luis', 'Contact' => array('PHONE' => '3010-7148', 'E-MAIL' => 'luis@net.com') ); arrKey2Lower($arr); var_dump($arr); ?> Expected result: ---------------- array(3) { ["id"]=> int(1) ["name"]=> string(4) "Luis" ["contact"]=> array(2) { ["phone"]=> string(9) "3010-7148" ["e-mail"]=> string(12) "luis@net.com" } } -- Edit bug report at http://bugs.php.net/bug.php?id=52917&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52917&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52917&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52917&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52917&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52917&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52917&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52917&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52917&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52917&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52917&r=support Expected behavior: http://bugs.php.net/fix.php?id=52917&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52917&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52917&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52917&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52917&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52917&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52917&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52917&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52917&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52917&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52917&r=mysqlcfg

« previous php.bugs (#154594) next »