How To List All Files In A Directory Using Php

RegisterLogin
How To List All Files In A Directory Using Php
Post Description: how to list all files in a directory using php
Tags: how, to, list, all, files, in, a, directory, using, php
This Post Was Posted On Oct 06, 2010 By Telmeasr #3566
hi, im kinda new to PHP, i am writing a script and i want to find a file in a directory, but first i have to get all the files which are located in a directory.

for example, lets say i have a directory tree like this:

./fruits
oranges.php
grapes.php
bananas.php
apples.php

as you can see i want to be able to get all these php files from code

does anyone know how about getting and listing all the current files from a folder?

thanks
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
sanders
#4509 1
you using this code:
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file<br>";
        }
    }
    closedir($handle);
} 
you can learn more at the php.net site: http://php.net/manual/en/function.readdir.php
Oct 06, 2010 Reply Report abuse
©2012 Webune Forums - Wed Dec 12, 2012 7:22 pm
Powered by: Webune Forums V3