Huijari Posted April 20, 2010 Share Posted April 20, 2010 So here's my code: I want it to do so if there is variable &number=5& in textfile1.txt and &number=8& in textfile2.txt then it should sort it textfile2 first in array and textfile1 next... $array = array(); // Open the local directory $Directory = opendir("."); // Read each file name while ($filename = readdir($Directory)) { // Deconstruct the file name to get the file suffix in lowercase $temp = explode(".", $filename); $fileSuffix = strtolower(end($temp)); // Only add to list if it ends in 'txt' if ($fileSuffix == "txt") { $file = file_get_contents($filename); // SOME CODE TO HERE THAT SEARCH VARIABLES FROM TXT FILES AND SORT BY ITS SIZE // like there is variable &number=5& in textfile1.txt and &number=7& in textfile2.txt // then it should sort it so textfile2.txt is first then textfile1.txt and so on.. // here below it just adds it in array for the last $addfile = pathinfo($filename, PATHINFO_FILENAME); array_push($array, "$addfile"); } } // Close directory closedir($Directory); Link to comment https://forums.phpfreaks.com/topic/199172-set-files-order-to-depending-size-of-variable/ Share on other sites More sharing options...
litebearer Posted April 20, 2010 Share Posted April 20, 2010 might give some idea... http://www.nstoia.com/toh/listdir.php Link to comment https://forums.phpfreaks.com/topic/199172-set-files-order-to-depending-size-of-variable/#findComment-1045465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.