jw06
March 20, 2006, 4:24pm
1
I’m having problems reading a directory into an array.
here is what I’m using to get a list of files:
<?php
function ls($path){
//Define Path
//$path = "/home/omnifiles/public_html";
$dir_handle = @opendir($path) or die("Unable to open $path");
//echo "Directory Listing Of $path<br />";
while ($file = readdir($dir_handle)){
if ($file != "." && $file != ".."){
"<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";
}
}
closedir($dir_handle);
}
$file is filled with names of files.
to display them
change this:
"<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";
into this:
echo "<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";
jw06
March 21, 2006, 4:36pm
3
Voccart:
$file is filled with names of files.
to display them
change this:
"<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";
into this:
echo "<a href='$file'>$file</a> extension: ". showExtension($file) . " filesize: ". fsize($file) ." permissions: " . fileperms($file) . "<br />";
Ok, sorry, when I was editing the code for the forum, I messed it up. I had echo in there, but echo only echoes that 1 file name. I want the whole directory listing to be placed into an array.