note 17952 deleted from function.mt-rand by jimw
| From: | jimw@php.net | Date: | Fri, 11 Jan 2002 21:48:51 +0000 |
| Subject: | note 17952 deleted from function.mt-rand by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24711@lists.php.net to get a copy of this message | ||
Just to add to what jamesmc submitted.
<?
$a = array("item 1","item 2","item
3","item 4","item 5","item 6","item
7","item 8");
mt_srand ((float) microtime() *
1000000);
# Replace the below line
# $r = mt_rand(0,7);
# with
$r = mt_rand(0, sizeof($a));
print"Random Value for today is: $a[$r]";
?>
At least this way, you never have to know the length of an array.
Big Din K.R.
massimo@gamebox.net