Re: Random number generator

From: Date: Wed, 05 Nov 2008 22:30:05 +0000
Subject: Re: Random number generator
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-282951@lists.php.net to get a copy of this message
Umm I must notify you, just in case you don't know this, that you have to be aware of the fact that the humanity haven't found a way to get a random number (yet..... they are working on it while I'm writing this..) (; On Wed, Nov 5, 2008 at 9:43 PM, Gary M. Josack <lists@byoteki.com> wrote: > WEISD wrote: > >> Just starting out, thanks. >> >> So, >> >> <?php >> >> $number = rand(1, 10); >> >> include('$number.html'); ?> >> >> >> I should have prefaced the question with, New to PHP... >> >> >> >> >> >> ""TG"" <tg-php@gryffyndevelopment.com> wrote in message >> news:20081105.190143.665.1@MAINLINE... >> >>> Here's how you generate a random number: >>> http://us.php.net/manual/en/function.rand.php >>> >>> There are a number of things you can do with that to select a random file >>> and >>> include it. Have an associative array where the random number matches an >>> array key and the value is the filename you want, is one method. >>> >>> Just starting out with PHP or is this a homework assignment? :) >>> >>> -TG >>> >>> ----- Original Message ----- >>> From: "WEISD" <pzig@weisd.com> >>> To: php-general@lists.php.net >>> Date: Wed, 5 Nov 2008 12:41:21 -0600 >>> Subject: [PHP] Random number generator >>> >>> >>>> On a php web page I want to generate a random number between say 1 and >>>> 10 >>>> and then use that number to reference a particular file in an include >>>> tag. >>>> >>>> <?php include('GeneratedNumber.html'); ?> >>>> >>>> Is there an easy way to do this? >>>> >>>> Thanks >>>> >>> >>> >> use double quotes instead of single quotes, else you will be trying to > literally include '$number.html' > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#282951) next »