how to read all the file names under certain directory ?

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 19
Joined: Wed Aug 17, 2005 6:00 am

Sun Aug 21, 2005 5:19 am

hi there ~
Is there any function that i can use to read all the file names (with or without the path does not matter) of a dirctory into an array ?
for example there are 5 files under a directory called "pix" those files are a.jpg b.jpg c.jpg d.jpg e.jpg
the output should be
$filename[0] = a.jpg
$filename[1] = b.jpg

ps. i need to display all the pics under a folder of my website ~ :oops:

User avatar
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Sun Aug 21, 2005 6:28 am

Take a look at PHP's readdir() function!
Gonçalo "gesf" Fontoura

Post Reply