PDA

Click to See Complete Forum and Search --> : get directories at location [Resolved]


ober0330
Feb 23rd, 2004, 07:08 AM
I have several folders on my website which all contain pages for different users. Is there any way to get the names of all of those folders so I can make links out of them on a page?

I tried using scandir(), but that's only a PHP 5 function and I'm running 4.3.4

The Hobo
Feb 23rd, 2004, 10:31 AM
If your setup is something like this:

users
user1
user2
user3

Then you can do:

<?php

if ($handle = opendir('/home/your_site/public_html/users')) {
while (false !== ($file = readdir($handle))) {
if (is_dir($file) && $file != '.' && $file != '..') {
echo $file . '<br />';
}
}

closedir($handle);
}
?>

That's just from memory, but something like that.

ober0330
Feb 23rd, 2004, 11:29 AM
Excellent. Thank you very much. :thumb: