BBS水木清华站∶精华区
发信人: thinkin (强强), 信区: Linux
标 题: File lister
发信站: BBS 水木清华站 (Thu Feb 17 11:04:15 2000)
<?
/*
This script read the filenames from a specified directory and returns them i
n an array.
The number of filenames is also returned.
Copyleft(L) 1999 Eric Persson, eric@persson.tm, http://www.persson.tm/script
s/
*/
Function searchdir($basedir)
{
global $filelisting, $number; //defines the two variables as global so they
can be accessed from outside the function
unset($filelisting); //kills $filelisting in case it have been used ear
lier in the script
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
};
searchdir( "./"); //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
?>
--
人生到处知何似?
应似飞鸿踏雪泥。
泥上偶然留指爪,
鸿飞那复计东西!
※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.37.191]
BBS水木清华站∶精华区