note 105891 modified in function.scandir by danbrown

From: Date: Fri, 23 Sep 2011 16:07:13 +0000
Subject: note 105891 modified in function.scandir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183386@lists.php.net to get a copy of this message
A simple function to get paths to all files in the subdirectories of the mentioned directory. Works well for small projects <?php function get_subdir_files($main_dir) { $dirs = scandir($main_dir); foreach($dirs as $dir) { if ($dir === '.' || $dir === '..') { continue; } $files=scandir($main_dir."/".$dir); foreach ($files as $file) { if ($file === '.' || $file === '..') { continue; } else { $result[]=$main_dir."/".$dir./".$file; } } } return $result; } ?> --was-- A simple function to get paths to all files in the subdirectories of the mentioned directory. Works well for small projects function get_subdir_files($main_dir) { $dirs = scandir($main_dir); foreach($dirs as $dir) { if ($dir === '.' || $dir === '..') { continue; } $files=scandir($main_dir."/".$dir); foreach ($files as $file) { if ($file === '.' || $file === '..') { continue; } else { $result[]=$main_dir."/".$dir./".$file; } } } return $result; } http://php.net/manual/en/function.scandir.php

« previous php.notes (#183386) next »