$images = scandir($this->gallery_path . $this->currGallery . DIRSEP); // Remove non images for ($i = 0; $i < count($images); $i++) { var_dump($this->gallery_path . $this->currGallery . DIRSEP . $images[$i]); var_dump(is_dir($this->gallery_path . $this->currGallery . DIRSEP . $images[$i])); echo "
"; if ($images[$i][0] == "." || !is_file($this->gallery_path . $this->currGallery . DIRSEP . $images[$i])) { unset($images[$i]); } } print_r($images); echo "
"; die();