检查文件夹中的最后一个js / css文件

I am building up a simple PHP script to get all my site css/js files combined.

What I would like to do now is checking for the most recent built css or js file in the "cache" folder.

So... some function like:

function getLastFile('js'){
   return the js file name
}

function getLastFile('css'){
   return the css file name
}

I've found out solutions on the net on how to check for the last file in some folder... but how can I exactly check the last by a specific extension?

if u mean last as most recent built

//get the last-modified-date of this very file
$lastModifiedTime=filemtime($Cachedfile);

or better have a look over the smartoptimizer Code , have a tiny look through its source u will surely get an idea

You can use the glob function.

For getting the js files, use glob('cache/*.js'); and for css glob(cache/*.css); And you can use filetime to get the latest modified file.

Refer to this question.