Page 1 of 1

Determine when pointer has reached end of array?

Posted: Sun Nov 13, 2005 4:36 pm
by fgomez
Hello,

I am using foreach to move through an array. I want to treat the last item differently than all the preceding ones. How do I determine when I've reached the the last spot?

Thanks!

Posted: Sun Nov 13, 2005 4:48 pm
by ambivalent
count the array elements, then decrement as you loop through it.

Determine when pointer has reached end of array?

Posted: Sun Nov 13, 2005 5:01 pm
by fgomez
Thank you. This did exactly what I needed it to.