Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
FileListerbasicCode Wizard, 12-30-2006 |
This script reads the filenames from a specified directory and returns them in an array.
The number of filenames is also returned..pretty simple but good to have at times.
<?php
*/
when i tested this script on my own box, it worked.
I'm not sure though, if it will work on yours, if it doesnt - clubber
me at irc.freshmeat.net - I can be found in #devnet as "teksys"
*/
$basedir = "/";
Function teksearch($basedir)
{
global $filelisting, $number; //defines the two variables as global.
unset($filelisting); // kills $filelisting, if it has been used already.
unset($number); //same as above
$handle=opendir($basedir);
while ($file = readdir($handle)) {
if ($file=="." or $file=="..") {
} else {
$filelisting[]="$basedir$file";
};
};
$number=sizeof($filelisting); //gets the size of the array
};
teksearch("/"); //runs the function to search the current directory.
echo $filelisting[1]; //echos the second value in the array.
echo $number; //echos the size of the array.
?>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

