I'm not sure what $nb is and i don't know exactally how the text file is formatted, so this might not work, but here is an example of how you would sort the results by number of occurances of each url:
if (! file_exists($COUNT_FILE)) {
error("Can't find file, check '\$COUNT_FILE' var...");
}
$file_arry = file($COUNT_FILE) or error("Can not open \$COUNT_FILE");
// creates empty array that each url will be stored in:
array($results);
// gets each url from the file:
while (list($key, $val) = each($file_arry)) {
// makes sure there is a value:
if ($val != "") {
// splits url from other data, i think:
list($file_url, $nb) = preg_split("/\t|\n/", $val);
// if the url is already in the array, that url is incremented
// if the url isn't in the array, it is added as a key
// when the loop finishes, the $results keys are all the urls
// the values in the array are the numbe of times each url occurs:
if (isset($results[$file_url])) {
$results[$file_url]++;
} else {
$results[$file_url] = 1;
}
// i don't know what $nb is, so i made another array to store the $file_url/$nb pairs:
$pairs[$file_url] = $nb;
}
}
// now that everything is captured into arrays, it must be sorted:
arsort($results);
// then we specify how many you want to view:
$show = 10; // just showing top 10 here, but you can change it
while (list($url, $count) = each($results) && $show > 0) {
echo ($url . " occurs " . $count . " times: " . $pairs[$url] . "<br>\n");
$show--; // counts down
}
again, i don't have a full understanding of the data being captured, so this may not help at all, but hopefully it does.