SPL is a collection of interfaces and classes that are meant to solve
standard problems.
- Directory iterator
- Recursive directory iterator
- SimpleXML iterator
- Ability to extend existing iterators
<?php
// Create directory iterator based on current directory
$dir = new DirectoryIterator(dirname(__FILE__));
// While there are valid entries
while ($dir->valid()) {
// Check if we are dealing with a file
if ($dir->isFile()) {
// print file name & its size
echo 'Name: ', $dir->getFilename(), ', ',
'Size: ', $dir->getSize(), '<br />';
}
// move to next entry
$dir->next();
}
?>