in reply to working backwards in an array element?

And if for some reason you did want to access an array from right to left (say in a foreach) you can always reverse it. $res[-1] is better here because all you want is the last element; reversing the whole array when you only want one item is wasteful.

Also note that you can use any negative index you like as long as there are enough elements, so in a 5-element array you could use up to -5 as an index.

  • Comment on Re: working backwards in an array element?