note 116424 added to class.recursivedirectoryiterator
| From: | yash at speedovation dot com | Date: | Thu, 01 Jan 2015 08:25:15 +0000 |
| Subject: | note 116424 added to class.recursivedirectoryiterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201287@lists.php.net to get a copy of this message | ||
$root = '/etc';
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
);
$paths = array($root);
foreach ($iter as $path => $dir) {
if ($dir->isDir()) {
$paths[] = $path;
}
}
print_r($paths);
Output:
Array
(
[0] => /etc
[1] => /etc/rc2.d
[2] => /etc/luarocks
...
[17] => /etc/php5
[18] => /etc/php5/apache2
[19] => /etc/php5/apache2/conf.d
[20] => /etc/php5/mods-available
[21] => /etc/php5/conf.d
[22] => /etc/php5/cli
[23] => /etc/php5/cli/conf.d
[24] => /etc/rc4.d
[25] => /etc/minicom
[26] => /etc/ufw
[27] => /etc/ufw/applications.d
...
[391] => /etc/firefox
[392] => /etc/firefox/pref
[393] => /etc/cron.d
)
----
Server IP: 72.52.91.14
Probable Submitter: 14.98.27.33
----
Manual Page -- http://php.net/manual/en/class.recursivedirectoryiterator.php
Edit -- https://master.php.net/note/edit/116424
Del: integrated -- https://master.php.net/note/delete/116424/integrated
Del: useless -- https://master.php.net/note/delete/116424/useless
Del: bad code -- https://master.php.net/note/delete/116424/bad+code
Del: spam -- https://master.php.net/note/delete/116424/spam
Del: non-english -- https://master.php.net/note/delete/116424/non-english
Del: in docs -- https://master.php.net/note/delete/116424/in+docs
Del: other reasons-- https://master.php.net/note/delete/116424
Reject -- https://master.php.net/note/reject/116424
Search -- https://master.php.net/manage/user-notes.php