php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30278 SPL: ArrayIterator: seek($postion) does not work
Submitted: 2004-09-29 19:08 UTC Modified: 2004-09-29 21:43 UTC
From: d dot peters at gmail dot com Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.1 OS: *
Private report: No CVE-ID: None
 [2004-09-29 19:08 UTC] d dot peters at gmail dot com
Description:
------------
http://www.php.net/~helly/php/ext/spl/classArrayIterator.html#a8

ArrayIterator::seek($position) always jumps to the 2nd element, no matter which value $position had...

I saw this in changelog:
Fixed bug #27042 (SPL: SeekableIterator seek() broken). (Marcus)

But it was fixed in 5.0.0 Beta4 and I use 5.0.1... 

Reproduce code:
---------------
$a = array(0,1,2,3,4,5,6,7,8,9);
$it = new ArrayIterator($a);
$it->rewind();

for ($i=0; $i < $it->count(); $i++)
{
  $it->seek($i);
  echo $it->current();
}

// output: 0111111111
// -> seek always jumps to the 1st position...


Expected result:
----------------
output: 0123456789

In my opinion it only makes sense to "seek" to the specified position... but correct my if i'm wrong ;-)

Actual result:
--------------
output: 0111111111

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-29 21:43 UTC] helly@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 15 13:00:02 2025 UTC