Thursday 15 April 2010

Php Grep Sort files by date descinding order with date -



Php Grep Sort files by date descinding order with date -

i want sort files in descending order date diplay, , using grep only

define("slash", stristr($_server[server_software], "win") ? "\\" : "/"); function php_grep($path){ $fp = opendir($path); while($f = readdir($fp)){ if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links $file_full_path = $path.slash.$f; if($file_full_path) { $ret .= "$file_full_path\n"; } } homecoming $ret; } echo "<pre>"; print_r(php_grep("/home"));

you can this:

class="lang-php prettyprint-override">function php_grep($path){ $ret = array(); $dates = array(); $fp = opendir($path); while($f = readdir($fp)){ if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links $file_full_path = $path.directory_separator.$f; if($file_full_path) { $ret[] = $file_full_path; } } array_multisort(array_map('filemtime', $ret), sort_numeric, sort_desc, $ret); homecoming $ret; } echo "<pre>"; php_grep("c:\workspace");

php grep

No comments:

Post a Comment