Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scan_folder($directory, $recursive)
- {
- global $images;
- if ($directory{0} != "/")
- {
- $directory = "/" . $directory;
- $relative = "." . $directory;
- }
- else
- {
- $relative = $directory;
- }
- if(is_readable($relative) && $dh = opendir($relative))
- {
- while(false !== ($file = readdir($dh)))
- {
- if(($file !== ".") && ($file !== ".."))
- {
- if(!is_dir($relative . $file) && is_readable($relative . $file))
- {
- if (pathinfo($file, PATHINFO_EXTENSION) == "png")
- {
- if ($relative{0} == "/")
- {
- array_push($images, $directory . $file);
- }
- else
- {
- array_push($images, "." . $directory . $file);
- }
- }
- }
- elseif($recursive)
- {
- scan_folder(".".$directory.$file."/", $recursive);
- echo ".".$directory.$file."/\n";
- }
- }
- }
- }
- return $images;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement