php - Sort files by date latest at top Using RecursiveDirectoryIterator -


By default, I do not want to display it by alphabet in the same way that I recursive directoryititor I want to sort the files using the latest files in descending order.

In addition to if the date to compare the situation is & amp; Get files from that date

  & lt ;? Php $ search_path = 'D: \ xampp \ htdocs'; $ File_extension = 'php'; $ It = new recurring directorytitle ("$ search_path"); $ Display = array ($ file_extension); Forex Currency (New Recursive Iterator Iterator $ $ as file) {$ test = Array (); $ Test = Explosion ("/", Date ("m / d / y", File Time ($ file))); $ Year = $ test [2]; $ Day = $ test [1]; $ Month = $ test [0]; If (($ year> = 2014) & amp; amp; ($ month> = 1) & amp; amp; amp; amp; amp; amp; amp; amp; amp; nbsp;% (& gt; = 15)) {echo " Lt; span style = 'color: red;' & Gt; "; Echo "& lt; b style = 'color: green;' & Gt; ". $ Days '-'. $ Month '-'. $ Year '& lt; / P & gt; & Lt; / span & gt; & lt; br & gt; From '$ file'. }}? & Gt;    

I do not know if you have a DirectoryIterator Before you can gather the results, get the time, then sort, who present it. Example:

  $ display = array ('php'); $ Files = new recurring altitude separator (new recurring directoryitter ($ search_path)); $ Data = array (); Foreign currency (files as $ $ $) {$ time = DateTime :: createFromFormat ('U', filemate ($ file- & gt; getPathname ())); // There is no need to explode time, just make it a datam object (if_are ($ file-> get-together extension), $ display) & amp; Amp; Amp; & Amp; $ Time & gt; New DateTime ('2014-01-15')) {// PHP and Zone 15 2014 $ data [] = array ('filename' =>; $ file- & gt; getPathname (), 'time' = & Gt; $ Time-> GetTimestamp ()); // push in)} usort ($ data, function ($ a, $ b) {// time latest return $ b ['time'] - $ a ['time'];}); Forex currency ($ data as $ key = & gt; $ value) {$ time = date ('Y-M-D', $ value ['time']); & Quot; $ Value [filename] & lt; / Span & gt; & Lt; Br / & gt; Akho "& lt; span style = 'color: red;' & Gt; & lt; b style = 'color: green;' & Gt; $ time & lt; / b & gt; "; }  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -