counting files
| From: | Nicholas W. Miller | Date: | Fri, 16 Feb 2001 18:18:08 +0000 |
| Subject: | counting files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-40193@lists.php.net to get a copy of this message | ||
I have a web page that displays an image. I would like to randomize
which image it displays when the page loads. Every possible image will
be the same dimensions and file format. Each image will be named a
consecutive number begining with 1.
The code I am using is:
$number = rand(1, 10);
$file = $number . "." . "gif";
echo"<img src = 'random_images/$file'>";
I'm wondering if there is a way to count how many files are in the
random_images directory, so I can dynamically set the range of my
rand(). This way I can add images to the random_images directory
without having to increase the range in the php code.
Thanks!
Nick