PHP check directories?

  • Thread starter Thread starter ben
  • Start date Start date
B

ben

Guest
Is it possible to use PHP to check what directories are in a folder and what thier names are?

Example: I have a folder called "Games". I want to check if there are any folders inside "Games". If there are, I want their names. How do I do this?
 
if(is_dir("games")){
echo "I am a dir";
}
else{
echo "isdir() returned Null/False";
}
 
<?php
if(!$handle = opendir('Games')) {
echo "Games is not a folder!";
}
else {
echo "reading games directory";
while(($obj = readdir($handle)) !== false) {
if(is_dir($obj)) {
echo "Directory found: $obj";
}
}
}
?>
 
Back
Top