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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

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

Post 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?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post 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()
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Post 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?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post 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.
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Post by djwk »

It's all sorted now, thanks for your help :)
Post Reply