Php Grep Sort files by date descinding order with date -
I want to sort files in descending order with a date to direct, and use only Grep
Define ("slash", strisor ($ _ server [SERVER_SOFTWARE], "win")? "\\": "/"); Function php_grep ($ path) {$ fp = opendir ($ path); While ($ f = readdir ($ fp)) {if (preg_match ("# ^ .. $ $", $ F)) continues; // Ignore symbolic links $ file_full_path = $ path.SLASH. $ F; If ($ file_full_path) {$ ret. = "$ File_full_path \ n"; }} $ Ret; } Echo "prefix"; Print_r (php_grep ("/ home"));
You can do something like this:
function php_grep ($ path) {$ ret = array}; $ Dates = array (); $ Fp = opendir ($ path); While ($ f = readdir ($ fp)) {if (preg_match ("# ^ .. $ $", $ F)) continues; // 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); Return $ ret; } Echo "prefix"; Php_grep ("C: \ workspace");
Comments
Post a Comment