spl DirectoryIterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a problem,

I need to turn an iterator into an array, but when I do, some methods I need to use stop working.

Take a look at the following example:

$dir = 'c:/';
$files = new DirectoryIterator($dir);
//$files = iterator_to_array($files);
foreach ($files as $file) {
    echo "{$file->getFileName()}<br>";//works
    echo "{$file->getPath()}<br>";//works
}

It works as expected. However, when the iterator is turned into an array:

$dir = 'c:/';
$files = new DirectoryIterator($dir);
$files = iterator_to_array($files);
foreach ($files as $file) {
    echo "{$file->getFileName()}<br>"; //does not work
    echo "{$file->getPath()}<br>";//works
}

It stops working. Can someone please help me, as a have tried and failed to find the cause of the problem.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux