I'm attempting to list all the folder names within a selected directory. Currently the only output is "." and ".." but my code is currently designed to remove them. Other than that there are directories within my test folder yet my output is just a blank page.
Here is the code:
class diring {
private $target = '/Users/Matthew/Documents/MDCMS/public_html/templates';
private $dirs = array();
private $err = array();
function readdirs() {
if (is_dir($this->target)) {
if ($handle = opendir($this->target)) {
while (false !== ($item = readdir($handle))) {
if (is_dir($item) && $item != "." && $item != "..") {
echo $item;
}
}
closedir($handle);
}
} else {
$this->err[] = 'The directory you are trying to access does\'nt exist. ';
$this->errs();
}
}
function errs() {
$errors = $this->err;
if (!empty($errors)) {
foreach ($errors as $error) {
echo $error;
}
}
}
}
Anybody know what i'm missing, looking through documentation this should be all i need to do to output the folder names.
Thanks