note 45993 deleted from faq.using by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 00:18:02 +0000 |
| Subject: | note 45993 deleted from faq.using by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77337@lists.php.net to get a copy of this message | ||
Note Submitter: E doubles
----
To mikasound:
You just need to open the directory, and test each item in it to see if it is a file or something
else. Use a counter to keep track.
<?php
$fileCount = 0; //Count files
$dirHandle = opendir('Your_Directory'); //Open Directory
while (false !== ($file = readdir($dirHandle))) { //Read items in directory
if(true == ($test = isfile($file))){ //test directory item to see if it is a file or not
$fileCount++; //increment file counter
}
}
random_number = rand($fileCount);
?>