PHP Scandir() error handling

Problem Solved. Using is_dir instead of scandir.