SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    opendir() files only

    hey everyone....

    How would you configure the opendir(), readdir() function (used to list files in a directory) not list directories. In other words, I only want it to display legit files (HTML, PHP, ASP, etc...no folders) Any ideas?

    Sketch
    Aaron Brazell
    Technosailor



  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First stop using opendir() it like if: else: is so 1998. Anyways on to the code.


    PHP Code:
    $dir "somedir/";
    $d dir($dir);
    while(
    $f $d->read()) {
        if(!
    is_dir($f)) {
            print 
    "$f<br>";
            }
        }
    $d->close(); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •