array_multisort, asort, keysort... help!!!!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

SmartAssDan
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Mar 09, 2003 4:33 pm

array_multisort, asort, keysort... help!!!!

Postby SmartAssDan » Sun Mar 09, 2003 4:40 pm

I'm building a database driven site. (of course)... and so, i'd like to do the following:

I'm going to add an entry to an array, and then want to sort it. Here's the array so far:


the array's name is "$scores"...

Code: Select all

Array
(
    [0] => Array
        (
            [score] => 210
            [name] => name
            [date] => 03/01/02 4:10pm
            [comment] => wow, that game was so much fun!
        )

    [1] => Array
        (
            [score] => 100
            [name] => name
            [date] => 03/01/02 4:10pm
            [comment] => i should play it again sometime!
        )

    [2] => Array
        (
            [score] => 90
            [name] => name
            [date] => 03/01/02 4:10pm
            [comment] => well, i could have done better...
        )

    [3] => Array
        (
            [score] => 10
            [name] => name
            [date] => 03/01/02 4:10pm
            [comment] => none
        )
)


then i'm gonna add a new element to that array:

Code: Select all

    [4] => Array
        (
            [score] => 100000
            [name] => newname
            [date] => 03/09/03 7:40:24pm
            [comment] => i beat you all!!
        )





now, what i would like to do is sort it by:


$scores[]["score"]]


(in other words, i want to sort it by top scores.)


i've been having lots and lots of problems with it. can i use array_multisort? or not? and if so... how?!

Thank you so much!

SmartAssDan
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Mar 09, 2003 4:33 pm

Postby SmartAssDan » Mon Mar 10, 2003 11:24 am

not that anybody rushed to help or anything, but i got around having to do this kind of sorting because of my database, and how it was organized. basically i avoided a problem in order to not have to deal with it. thanks for not helping. too bad there isn't a smiley for :bitter:....

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Postby WiZARD » Wed Mar 12, 2003 4:42 am



Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest