Re: Random number generator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:20081105.190143.665.1@xxxxxxxxxxx
>>
>>> 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@xxxxxxxxx>
>>> To: php-general@xxxxxxxxxxxxx
>>> Date: Wed, 5 Nov 2008 12:41:21 -0600
>>> Subject:  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
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux