RE: [PHP] Random array element
| From: | Sean Malloy | Date: | Tue, 07 Jan 2003 23:39:29 +0000 |
| Subject: | RE: [PHP] Random array element | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130654@lists.php.net to get a copy of this message | ||
// seed code
list($usec, $sec) = explode(' ', microtime());
$microtime = ((float)$usec + (float)$sec);
srand((double) $microtime * 1000000);
//~ seed code
$randNumber = array();
$weekday =
array("monday","tuesday","wednesday","thursday","friday","saturday","sunday"
);
for ($p = 0; $p < 10; $p++)
{
randNumber[] = rand(0, 6); // rand(int minnumber, int maxnumber);
}
$randDay1 = weekday[randNumber[0]];
$randDay2 = weekday[randNumber[1]];
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php