how, when reading a directory structure, can i ignore the ".." and "." directories??
i'm using the below code to list all directories, and the files underneath. it works except for the first two directories it finds ".." and ".", it also lists all files under that.
i'd prefer the code ignore those two directories.
thanks in advance
//reading the directory structure
$dir = "../";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
//here, if the $file is a directory, i want to search all files under that directory
if (is_dir($dir.$file)) {
$newdir = ($dir.$file);
$dirname = ($file);
print "directory name: $dirname";
if($ah = opendir($newdir)){
while (($filename = readdir($ah)) !== false) {
echo " file: $filename <br />";
}
}
//echo "this is a directory, y'all";
echo "<br />";
}
}
closedir($dh);
}
}