note 87219 deleted from function.glob by danbrown

From: Date: Tue, 25 Nov 2008 15:55:16 +0000
Subject: note 87219 deleted from function.glob by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146929@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- <?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')); ?>

« previous php.notes (#146929) next »