DirectoryIterator::seek ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mickeyf
Forum Newbie
Posts: 3
Joined: Mon Jul 27, 2009 5:18 pm

DirectoryIterator::seek ?

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: DirectoryIterator::seek ?

Post 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
 
mickeyf
Forum Newbie
Posts: 3
Joined: Mon Jul 27, 2009 5:18 pm

Re: DirectoryIterator::seek ?

Post by mickeyf »

Thanks - I was afraid something like that might be the problem...
Post Reply