note 31335 added to function.array-rand
| From: | Paul at rack1 dot php dot net | Date: | Thu, 17 Apr 2003 18:40:11 +0000 |
| Subject: | note 31335 added to function.array-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46747@lists.php.net to get a copy of this message | ||
If you trying to get a randon array just use that... it's easier! And you have no repeats...
<?
srand ((float) microtime() * 10000000);
$input = array ("Neo", "Morpheus", "Trinity", "Cypher",
"Tank");
$keys = array_rand ($input, sizeof($input));
while (list($k, $v) = each($keys))
{
echo $new_input = $input[$v];
}
?>
--
http://www.php.net/manual/en/function.array-rand.php
http://master.php.net/manage/user-notes.php?action=edit+31335
http://master.php.net/manage/user-notes.php?action=delete+31335
http://master.php.net/manage/user-notes.php?action=reject+31335