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.
Listing files in directory and files in sub directory
Moderator: General Moderators
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
well
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>- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
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/>";
}
?>