SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to sort multi-dimension array?

    I am trying to automatically sort the following array in alphabetic order. Can anyone show me how this is done? I figured out how to sort one dimension, but not two....

    (There are about 1000 values in this array, but I have shown only 4 here for example.)

    PHP Code:
    $SERVER_INFO[1]['server'] = "zzz.server.com";
    $SERVER_INFO[1]['display_name'] = "zzz";
    $SERVER_INFO[1]['more_info'] = "info/?template=orange";
     
    $SERVER_INFO[2]['server'] = "dfs.server.com";
    $SERVER_INFO[2]['display_name'] = "dfs";
    $SERVER_INFO[2]['more_info'] = "info/?template=orange";
     
    $SERVER_INFO[3]['server'] = "ssss.server.com";
    $SERVER_INFO[3]['display_name'] = "ssss";
    $SERVER_INFO[3]['more_info'] = "info/?template=orange";
     
    $SERVER_INFO[4]['server'] = "eee.server.com";
    $SERVER_INFO[4]['display_name'] = "eee";
    $SERVER_INFO[4]['more_info'] = "info/?template=orange"
    So I would like to sort the array based on the alphabetic value of the $SERVER_INFO[9]['server'] variable.

    Thanks!

  2. #2
    Non-Member QualityWebHosts's Avatar
    Join Date
    Sep 2003
    Location
    USA
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this link and let me know if you still have questions.
    http://www.php.net/sort

  3. #3
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, array_multisort might be what you are looking for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •