OpenSRS/osrs-toolkit-php — pull request #8 by detain (2014-05-19 19:03:46+00:00)
Title: Reworked the DirectoryIterator line to work with all versions of PHP5

Some versions of PHP like 5.2 dont properly implement the ability to
simply foreach loop the Iterator.

Heres an example:
// /home contains 3 directories: larry, curly, moe
$d = new DirectoryIterator('/home');
foreach ($d as $i)
echo "$i";

PHP 5.2 output:
larry
larry
larry

PHP 5.3+ output:
larry
curly
moe

The DirectoryIterator is still very usable with its class calls, so I reworked the code like this:

$d = new DirectoryIterator('/home');
while($d->valid()) {
echo $d->getFilename();
$d->next();
}

The new code will work with all versions of PHP5+