get a list of files in a directory

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
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

get a list of files in a directory

Post by psychotomus »

how can i get a list of files in a directory?
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Using readdir()

Code: Select all

<?php
    if ($handle = opendir('.')) {
        while (false  !== ($file = readdir($handle))) {
            if ($file  != "." && $file  != "..") {
                echo "$file\n";
            }
        }
        closedir($handle);
    }
?>
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

thnx
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

No problem, glad I could be of assistance to you ;)
Post Reply