note 110441 deleted from function.require by aharvey

From: Date: Tue, 23 Oct 2012 02:19:32 +0000
Subject: note 110441 deleted from function.require by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191489@lists.php.net to get a copy of this message
Note Submitter: wolfzoon at hotmail dot com ---- Now that was some painful indentation, let me fix that for ya: And shouldn't that final "$path" be "$path/$value"? \quote Here's a simple function to include all files from folder / subfolders. <?php function require_path($path) { $root = scandir($path); $files = array(); foreach($root as $value) { if($value === '.' || $value === '..') {continue;} if(is_file("$path/$value")) { $pInfo = pathinfo($value); if ($pInfo['extension'] == "php") { require_once("$path/$value"); echo "$path/$value<br>"; } } else { require_path("$path/$value"); } } } ?> Hope that helps !!!

« previous php.notes (#191489) next »