I have a file here which contains list of database names and its corresponding size. Now I want to sort the size from the largest to the lowest, and the database name should go along it upon display.Am using PHP here.. Can anyone help me out?
Here's a simple code for that:
$file_name = test.txt
$handle = @fopen($file_name, "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$data = explode(" ",$buffer);
echo $data[1]."\n";
}
fclose($handle);
}
File looks like this:
DatabaseName 300 KB
Note: $data[1] contains the sizes. Should i place it on an array? how about the db name?
Answers are very much appreciated. =)