Page 1 of 1
Listing files in directory and files in sub directory
Posted: Thu Sep 14, 2006 7:37 am
by winsonlee
How am I able to list the files in directories and sub directory using glob function ??
If i am not wrong glob can only list files in the particular directory but not all the files in the subdirectory.
Posted: Thu Sep 14, 2006 8:11 pm
by feyd
Why did you create a new thread on this?
There is a thread in Code Snippets (I believe) regarding the creation of a directory tree. It may be of interest.
well
Posted: Thu Sep 14, 2006 9:07 pm
by akimm
If you haven't found the code snipplet yet I can give you an idea how use glob()
Code: Select all
<table>
<tr>
<?php
foreach (glob("sample_dira/sample_dirb/*.php") as $dir) {
echo '<td>' . $dir . '</td>';
}
?>
</tr></td>
Posted: Thu Sep 14, 2006 9:24 pm
by akimm
And this will list the contents of the dir as a link
Code: Select all
<?php
foreach (glob(sample_dir/sample_dir/"*.*") as $filename)
{
echo "<a href=\"".$filename."\">".$filename."</a><br/>";
}
?>