[SOLVED] Directory's Content

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tempest
Forum Newbie
Posts: 10
Joined: Sat Jan 08, 2005 12:33 pm

Directory's Content

Post by Tempest »

I was just wondering if there was a way i could list all the files not including the folders on a page?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]glob()[/php_man] or [php_man]opendir()[/php_man]
Tempest
Forum Newbie
Posts: 10
Joined: Sat Jan 08, 2005 12:33 pm

Post by Tempest »

hehe see im realy new to php how exactly would i use that?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Have you visited the links?
Try it out, post what you came up with.
Tempest
Forum Newbie
Posts: 10
Joined: Sat Jan 08, 2005 12:33 pm

Post by Tempest »

i read the pages but i come out with errors i tried using glob but it didn't work :\
can you give me an example cause the example on the site didn't help
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

glob() is only available in more recent versions of php (newer than 4.3.0). You may have an older version. Try the examples on opendir()'s page.
Tempest
Forum Newbie
Posts: 10
Joined: Sat Jan 08, 2005 12:33 pm

Post by Tempest »

Code: Select all

$dir = "/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file<br>";
}
closedir($dh);
}
}
i have that but its showing files that are not even in the directory that the file is in


NVM i fixed that thanks for all your help :D


feyd | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Post Reply