note 106229 deleted from function.is-file by danbrown

From: Date: Thu, 20 Oct 2011 17:07:10 +0000
Subject: note 106229 deleted from function.is-file by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184026@lists.php.net to get a copy of this message
Note Submitter: mariovillalobos2011 at gmail dot com ---- Another approach on how to get all php files inside a directory <?php $allDirs = array(array('/absolute/path/of/folder')); $dirLevel = 0; $searchFactor = 0; $searchPath = ''; $keepLooking = TRUE; while ($keepLooking) { $tmp = array(); foreach ($allDirs[$dirLevel] as $searchPath) { foreach (scandir($searchPath) as $filename) { $host = $searchPath.'/'.$filename; if (is_dir($host) && substr($filename, 0, 1) != '.') { $searchFactor++; array_push($tmp, $host); } elseif (is_file($host)) { $forExt = explode('.', $host); if ($forExt[count($forExt) - 1] == 'php' && substr($filename, 0, 1) != '.') echo $host.'<br/>'; } } } if ($searchFactor > 0) { $dirLevel++; array_push($allDirs, $tmp); $searchFactor = 0; } else $keepLooking = FALSE; } ?>

« previous php.notes (#184026) next »