note 60745 added to function.array-change-key-case

From: Date: Sun, 15 Jan 2006 19:15:10 +0000
Subject: note 60745 added to function.array-change-key-case
Groups: php.notes 
Request: Send a blank email to php-notes+get-101862@lists.php.net to get a copy of this message
Although you aren't supposed to be asking for help on the notes section, here is a function that will do what you asked. It can't be between 1 and 100 because for any array with over 10 keys, there would be issues; this function goes between 1 and 1000: <?php function array_change_keys($array) { $used = array(); foreach ($array as $key=>$value) { $newkey = $key; for ($i = 0; $i < 1000; $i++) { $i = rand() % 1000; if ((($i % 10) == 0) && !in_array($i,$used)) { break; } } $newkey .= "_".$i; $newarray[$newkey] = $value; } return $newarray; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-change-key-case.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60745 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60745&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60745&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101862) next »