how to read the the arrays in a foreach or for loop from last to first?

Discussion in 'PHP' started by w47w47, Nov 17, 2009.

  1. #1
    also... that the output would look like this:

    9
    8
    7
    6
    5
    4
    3
    2
    1
    0

    and not like that:

    0
    1
    2
    3
    4
    5
    6
    7
    8
    8
    9
     
    w47w47, Nov 17, 2009 IP
  2. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    also this works for me:

    for($i=$c;$i>=0;$i--){

    but i get this error:

    Notice: Undefined offset: 2
     
    w47w47, Nov 17, 2009 IP
  3. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i have figured it out myself. ;)

    just had to add -1 to $c.

    thread closed. :>
     
    w47w47, Nov 17, 2009 IP