Php Code > Grab directory listings into an array the example prints out each

feige 1 years ago 64 readed 0Fav, Cancel Fav

    Php Code > Grab directory listings into an array the example prints out each

PHP
Grab directory listings into an array the example prints out each

<html> 
<head> 
        <title>SHOW DIRS</title> 
</head> 

<body> 
<? 

#this is the directory you want to index 
$startdirname = "/home/sites/site7/pics/"; 

#if you want to work in the current dir, uncomment the next line 
//$startdirname= exec("pwd"); 

#this is the extension of the files you want to play with 
#standard UNIX and derivatives wildcards are allowed 
$ext = "jpg"; 



$dir = exec("ls -l $startdirname", $allentries,$dead); 
for ($index=0; $index<count($allentires); $index++){ 
echo " $allentries[$index] <BR>"; 
} 



#$dir = dir("."); 
$dir = dir("$startdirname"); 

while ($file = readdir($dir)){ 

        if ( !eregi ("(^\.)|(*\.)", $file) ) { 
                $dirs[] = $file; 
                $dirnumber = count($dirs); 
        } 
} 
echo "<HR>"; 
for ($i=0; $i < $dirnumber; $i++){ 
echo $dirs[$i]; 
echo "<hr>"; 
} 


?> 
</body>