array in reverse order...

Discussion in 'PHP' started by ignas2526, Dec 16, 2008.

  1. #1
    Hello,
    I searching for function which will reverse order of array like this:
    $array[0]='something';
    $array[1]='and';
    $array[2]='or';
    $array[3]='nothing';
    PHP:
    to
    $array[0]='nothing';
    $array[1]='or';
    $array[2]='and';
    $array[3]='something';
    PHP:
    Thanks.
     
    ignas2526, Dec 16, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    <?php
    
    $array[0]='something';
    $array[1]='and';
    $array[2]='or';
    $array[3]='nothing';
    
    $reversed = array_reverse($array);
    print_r($reversed);
    
    ?>
    PHP:
    Returns:
    Array
    (
        [0] => nothing
        [1] => or
        [2] => and
        [3] => something
    )
    Code (markup):
     
    Danltn, Dec 16, 2008 IP
  3. ignas2526

    ignas2526 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    dude... so easy, i really need to lockup google twice b4 posting...
    Thanks.
     
    ignas2526, Dec 16, 2008 IP
  4. atlantadentalcenter

    atlantadentalcenter Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ya, and is a great list of PHP array function here for your future reference: h_ttp://www.w3schools.com/PHP/php_ref_array.asp
     
    atlantadentalcenter, Dec 17, 2008 IP
  5. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    chopsticks, Dec 17, 2008 IP
  6. Yesideez

    Yesideez Peon

    Messages:
    196
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    They're also listed here: uk.php.net/array
     
    Yesideez, Dec 17, 2008 IP
  7. herbacious

    herbacious Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yep

    php online documentation is the mutts nuts
     
    herbacious, Dec 19, 2008 IP