6

Possible Duplicate:
Best way to get files from a dir filtered by certain extension in php

Are there any native WP functions that are able to list files based by extension from a directory? if not, how do I do this with php?

I want to get the file names of all .css files from a certain folder

Community
  • 1
  • 1
Alex
  • 66,732
  • 177
  • 439
  • 641

3 Answers3

6

Use glob like so:

$file_paths = glob('/path/to/files/*.extension');
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
5

Check out the glob function

$files=glob("/path/to/your/folder/*.css");
foreach ($files as $file) {
    echo "$file<br>";
}
Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
5

I don't know about wordpress

But in PHP, you want the glob command - http://php.net/glob

James
  • 3,265
  • 4
  • 22
  • 28
  • thanks, but I get the server file path. is there any way I can get only the short file name? – Alex Jul 05 '10 at 22:32