php - How to sort folders based on content in a file within them -
I am working on a script in PHP which presents the document stored in a directory tree
My directory tree looks something like this:
* mainfolder1 + subfolder1 - subsubfolder1 - subsubfolder2 + subfolder2 - subfolder 3 - subfolder 4 Within each subsubfolder is a file named data.dat in which number I create an array Want Data DAT
You can use the class to go through the main dior, then the results After filtering it, it's about sorting the way you want just one array.
Here's an example:
& lt ;? Php $ iterator = new recurring iterator iterator (new recursive directorytitle ('.')); $ Data files = new regedititter ($ Etherreter, '/data.dat$/i', recursive reactor iterator :: GE_MATCH); $ Directory = array (); Foreign Currency ($ datafile $ name = & gt; $ item) {$ directory [dynamite ($ name)] = (int) file_get_contents ($ name); } Asort ($ directory); Print_r (array_keys ($ directory));
Comments
Post a Comment