RE: [PHP] rand()
| From: | Demitrious S. Kelly | Date: | Thu, 14 Mar 2002 05:46:08 +0000 |
| Subject: | RE: [PHP] rand() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88441@lists.php.net to get a copy of this message | ||
And I just realized how redundant the checks for less then and grater
then the rand min and rand max are...
Oh well... I'm tired :)
-----Original Message-----
From: Demitrious S. Kelly [mailto:apokalyptik@apokalyptik.com]
Sent: Wednesday, March 13, 2002 9:45 PM
To: 'Jeff Sittler'; php-general@lists.php.net
Subject: RE: [PHP] rand()
Something to the effect of
$num=0;
do {
$num=rand(33,146);
if ( $num > 90 && $num < 125 ) {
$num=0;
} else if ( $num > 146 || $num < 33 ) {
$num=0;
}
} while ( $num == 0 );
note: ths is just off the top of my head... check for validity and
syntax.
-----Original Message-----
From: Jeff Sittler [mailto:jsittler@mindblender.com]
Sent: Wednesday, March 13, 2002 9:31 PM
To: php-general@lists.php.net
Subject: [PHP] rand()
I am wanting to use rand() to generate a number between 33-90 OR
125-146.
Is there a way to do this? I don't want any numbers before 33 or
between
91-124 or after 146. Could someone point me in the direction I need to
look
to accomplish this.
Thanks,
Jeff
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php