Displaying just Dirs
Moderator: General Moderators
Displaying just Dirs
I wrote a script to print out all dirs and files. Now I am trying to edit it so that it only shows the Dirs. I did it on a previous code that I wrote, but this one just seems to ignore it. Also is there a way to split up the file names and dirs. So instead of showing the full path, it will only show the file name and one directory up for example?The Code Thanks for the help.
Hope this helps
Code: Select all
<?php
if ($handle = opendir('foldertoloop/')) {
while (false !== ($file = readdir($handle)))
{
print"the directory or file is: $file\n";
}
closedir($handle);
?>I think I was misunderstood. I already created a script http://pavilionhome.dyndns.org:45/test.txt or .php if you want to see it in action. When I set the dir to /tmp or some other dir on the linux box it works and only lets me see the dirs not files. But when I point it on a mounted drive it lists alllll the files. I can't figure out why.
The other part of my question is about printing the path. Instead of printing /tmp/sub1/sub2/file.ext, I need to know if you can just it to print one sub directory or /sub2/file.ext?
Thanks for the help.
The other part of my question is about printing the path. Instead of printing /tmp/sub1/sub2/file.ext, I need to know if you can just it to print one sub directory or /sub2/file.ext?
Thanks for the help.