Help with prev, next

From: Date: Tue, 20 Feb 2001 04:40:38 +0000
Subject: Help with prev, next
Groups: php.general 
Request: Send a blank email to php-general+get-40689@lists.php.net to get a copy of this message
Hi, I'm getting some weird behavior from prev() and next(). If anyone knows what's going on please let me know. Also, please make sure you e-mail me personally in addition to the list. Anyway, here's the problem. Check out the following code: <?php $arr = Array(1, 2, 3, 4); echo current($arr) . "<br>"; #prints out 1 echo next($arr) . "<br>"; #prints out 2 echo next($arr) . "<br>"; #prints out 3 echo next($arr) . "<br>"; #prints out 4 echo prev($arr) . "<br>"; #prints out 3 echo prev($arr) . "<br>"; #prints out 2 echo prev($arr) . "<br>"; #prints out 1 ?> It does the expected and prints out 1234321 (without the <br>s). However, if I add one more call to next() in there, it only prints out 1234. It seems like the call to next that goes past the end of the array sort of "breaks" it so you can't go back again. If I do a call to end() it prints out 4, so the array still 'works', but I can't get back using prev(). Anyone know why? Thanks! Keith

« previous php.general (#40689) next »