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