Page 1 of 1

[SOLVED] Listing data in order (most to least)

Posted: Wed May 03, 2006 2:24 pm
by djwk
Ok, What I am doing right now is certain links on my website i am using count.php to save how many clicks it has had to file.

Lets say I have 10 files each with a number of clicks wrote to it.

I've opened these files and put them into variables ("$1" - "$10")


Now I want to sort them into order starting with the most number of clicks to the least (and any of the same number of clicks can just be randomly placed but still in the right place on the list)

I know i've explained that in a really bad way lol but does anyone understand and can help?

Posted: Wed May 03, 2006 2:41 pm
by Oren
I'm not sure I understand what you are talking about :?
Anyway, I think what you want to do is creating an array with all this "clicks info" and then use rsort()

Posted: Wed May 03, 2006 4:22 pm
by djwk
Ok, almost working, I am using krsort() however when 2 items in the array have the same number "here"=>"" then it just doesnt show them. Is there any way I can stop this happening?

Posted: Wed May 03, 2006 6:17 pm
by Ollie Saunders

Code: Select all

echo print_r($yourArray); // and post output here in this thread
should be able to help you more easily then

Posted: Thu May 04, 2006 2:48 am
by CoderGoblin
If there any reason you are saving this information to a file and not a database? The database selection of such information could then sort the information for you as well as saving it for statistical purposes at a later date.

Posted: Thu May 04, 2006 2:56 am
by Oren
As ole said, post here your array and bellow it post the array that looks like what you want it to be so we can help you with that.

Posted: Sat May 06, 2006 11:30 am
by djwk
It's all sorted now, thanks for your help :)