php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37598 prev() fonction crash the array pointer
Submitted: 2006-05-26 01:58 UTC Modified: 2006-05-26 02:42 UTC
From: jerebenz at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.2 OS: Unix
Private report: No CVE-ID: None
 [2006-05-26 01:58 UTC] jerebenz at gmail dot com
Description:
------------
Hi,

The problem occur the pointer of an array is at the start and I do a prev().

If I try to do current() after that, I see nothing, and if I try next() and current() again, still nothing.

Bye

Reproduce code:
---------------
<?php

$tab = array('4', '6');

echo current($tab);

prev($tab);
echo current($tab);

next($tab);
echo current($tab);

?>

Expected result:
----------------
446

Actual result:
--------------
4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-26 02:08 UTC] jerebenz at gmail dot com
Hi,

The problem occur when the pointer of an array is at the start and I do a
prev().

If I try to do current() after that, I see nothing, and if I try next()
and current() again, still nothing.

Bye
 [2006-05-26 02:42 UTC] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You should check the return value of prev and next. The state is undefined as out of range. Reset the array after having reached the end or beginning.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 04:01:28 2025 UTC