note 87220 added to function.glob
| From: | php | Date: | Tue, 25 Nov 2008 10:35:40 +0000 |
| Subject: | note 87220 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146906@lists.php.net to get a copy of this message | ||
<?php
// $Id: rglob.php,v 1.0 2008/11/24 17:20:00 hm2k Exp $
/**
* Recursive glob()
*/
/**
* @param int $pattern
* the pattern passed to glob()
* @param int $flags
* the flags passed to glob()
* @param string $path
* the path to scan
* @return mixed
* an array of files in the given path matching the pattern.
*/
function rglob($pattern='*', $flags = 0, $path='')
{
$paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
$files=glob($path.$pattern, $flags);
foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); }
return $files;
}
/* example usage: */
chdir('../');
var_export(rglob('*.php'));
?>
----
Server IP: 69.147.83.197
Probable Submitter: 82.152.138.226
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/87220
Del: integrated -- https://master.php.net/note/delete/87220/integrated
Del: useless -- https://master.php.net/note/delete/87220/useless
Del: bad code -- https://master.php.net/note/delete/87220/bad+code
Del: spam -- https://master.php.net/note/delete/87220/spam
Del: non-english -- https://master.php.net/note/delete/87220/non-english
Del: in docs -- https://master.php.net/note/delete/87220/in+docs
Del: other reasons-- https://master.php.net/note/delete/87220
Reject -- https://master.php.net/note/reject/87220
Search -- https://master.php.net/manage/user-notes.php