1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

array sorting

Discussion in 'PHP' started by moiseszaragoza, Jan 17, 2010.

  1. moiseszaragoza

    moiseszaragoza New Member

    Joined:
    Jan 17, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    array sorting
    I have a array that holds 2 values a userid and a score.

    but i want to show the hiest scores on top.
    but its not working. this is what i am trying

    PHP Code:
    PHP:
    $array_userid_score['score'][$count_userid_score]     = 1;
    $array_userid_score['users_id'][$count_userid_score]     = 0;

    $array_userid_score['score'][$count_userid_score]     = 10;
    $array_userid_score['users_id'][$count_userid_score]     = 1;

    $array_userid_score['score'][$count_userid_score]     = 9;
    $array_userid_score['users_id'][$count_userid_score]     = 2;

    $array_userid_score['score'][$count_userid_score]     = 15;
    $array_userid_score['users_id'][$count_userid_score]     = 3;

    $array_userid_score['score'][$count_userid_score]     = 6;
    $array_userid_score['users_id'][$count_userid_score]     = 4;

    asort ($array_userid_score);
    But I am not getting it by the score

    Thanks for the help
     
  2. Deadly Ghos7

    Deadly Ghos7 New Member

    Joined:
    Dec 19, 2009
    Messages:
    55
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Earth
    Home Page:
    hi bro, I suppose there are good things over the following links:
    Code:
    http://php.net/manual/en/function.sort.php
    http://www.informit.com/articles/article.aspx?p=31840&seqNum=6
    
     

Share This Page