note 60745 deleted from function.array-change-key-case by bjori

From: Date: Fri, 14 Apr 2006 13:24:12 +0000
Subject: note 60745 deleted from function.array-change-key-case by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108068@lists.php.net to get a copy of this message
Note Submitter: cmorell184 at comcast dot net ---- 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; } ?>

« previous php.notes (#108068) next »