Page 1 of 1

DirectoryIterator::seek ?

Posted: Mon Jul 27, 2009 5:32 pm
by mickeyf
I have recently started using DirectoryIterator. (php v 5.2.8 ) The methods I have tried so far do work, except seek. If I try the following code, I get a correct 'count' but then php complains:

"Fatal error: Call to undefined method DirectoryIterator::seek()"

Code: Select all

 
    $dir = new DirectoryIterator( '//Servername/QA/Builds' );       
    $count = 0;
    while($dir->valid()) {
        $dir->next();
        $count++;
    }
    echo $count;
    while($count > 0 ) {
        $dir->seek($count--);
          ......
    }
 
have I missed something basic?

thanks

Re: DirectoryIterator::seek ?

Posted: Mon Jul 27, 2009 6:19 pm
by Weirdan
DirectoryIterator does not implement SeekableIterator and does not have seek() method (at least in PHP 5.2.9). Manual seems to be talking about newer release.

Here's a hint:
Use the following command to inspect built-in classes:

Code: Select all

 
php --rc DirectoryIterator
 

Re: DirectoryIterator::seek ?

Posted: Mon Jul 27, 2009 6:29 pm
by mickeyf
Thanks - I was afraid something like that might be the problem...