Alphabetically ordering an array?

Discussion in 'PHP' started by Darkhodge, Jul 10, 2006.

  1. #1
    If I have an array of filenames, is there a way I can reorder it so it is alphabetic from a-z?

    Thanks
     
    Darkhodge, Jul 10, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The book, Using Arrays in PHP says to generate an alphabetcal sort do this::

    $products = array( 'Tires', 'Oil', 'Spark Plugs' );
    sort($products);
    Code (markup):
     
    clancey, Jul 10, 2006 IP
  3. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #3
    So just a simple inbuild sort() function will do it?!?! Wow thats so simple. :D

    Will research into that function in the manual as I hadnt heard of it before.
     
    Darkhodge, Jul 11, 2006 IP
  4. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Their is a hole bunch of functions for sorting an manipulating an array. Check out php.net/array
     
    drewbe121212, Jul 17, 2006 IP
  5. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #5
    Cheers for the info but the sort() function worked great :)
     
    Darkhodge, Jul 17, 2006 IP