note 114434 added to class.directoryiterator
| From: | abdel at elghafoud dot com | Date: | Thu, 20 Feb 2014 11:39:44 +0000 |
| Subject: | note 114434 added to class.directoryiterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198559@lists.php.net to get a copy of this message | ||
Shows us recursively all files and catalogues in directory except "." and "..".
<?php
/**
* @param string $directory
* @param array $files
* @return array
*/
public function recursiveDirectoryIterator ($directory = null, $files = array()) {
$iterator = new \DirectoryIterator ( $directory );
foreach ( $iterator as $info ) {
if ($info->isFile ()) {
$files [$info->__toString ()] = $info;
} elseif (!$info->isDot ()) {
$list = array($info->__toString () => $this->recursiveDirectoryIterator(
$directory.DIRECTORY_SEPARATOR.$info->__toString ()
));
if(!empty($files))
$files = array_merge_recursive($files, $filest);
else {
$files = $list;
}
}
}
return $files;
}
?>
----
Server IP: 195.26.5.11
Probable Submitter: 213.135.245.173
----
Manual Page -- http://php.net/manual/en/class.directoryiterator.php
Edit -- https://master.php.net/note/edit/114434
Del: integrated -- https://master.php.net/note/delete/114434/integrated
Del: useless -- https://master.php.net/note/delete/114434/useless
Del: bad code -- https://master.php.net/note/delete/114434/bad+code
Del: spam -- https://master.php.net/note/delete/114434/spam
Del: non-english -- https://master.php.net/note/delete/114434/non-english
Del: in docs -- https://master.php.net/note/delete/114434/in+docs
Del: other reasons-- https://master.php.net/note/delete/114434
Reject -- https://master.php.net/note/reject/114434
Search -- https://master.php.net/manage/user-notes.php