Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP + Wordpress - get a list of files from a directory [duplicate]

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

like image 306
Alex Avatar asked Jul 05 '10 22:07

Alex


3 Answers

Use glob like so:

$file_paths = glob('/path/to/files/*.extension');
like image 154
amphetamachine Avatar answered Oct 01 '22 10:10

amphetamachine


I don't know about wordpress

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

like image 28
James Avatar answered Oct 01 '22 09:10

James


Check out the glob function

$files=glob("/path/to/your/folder/*.css");
foreach ($files as $file) {
    echo "$file<br>";
}
like image 33
Paul Dixon Avatar answered Oct 01 '22 08:10

Paul Dixon