note 45993 added to faq.using

From: Date: Sat, 25 Sep 2004 19:31:07 +0000
Subject: note 45993 added to faq.using
Groups: php.notes 
Request: Send a blank email to php-notes+get-77317@lists.php.net to get a copy of this message
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); ?> ---- Manual Page -- http://www.php.net/manual/en/faq.using.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45993 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45993&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45993&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77317) next »