Advertisement
Guest User

teacher

a guest
May 27th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1.  
  2. function my_scan_dir($dir) // it works, for now.........
  3. {
  4. if (is_dir($dir))
  5. {
  6. // detect if the path has arabic characters and convert it so it works
  7. if (preg_match('#[\x{0600}-\x{06FF}]#iu', $dir))
  8. {
  9. $dir = iconv("utf-8", "windows-1256", $dir);
  10. }
  11. if ($handle = opendir('.')) {
  12. while (false !== ($file = readdir($handle)))
  13. {
  14. if ($file != "." && $file != ".." && strtolower(substr($file, strrpos($file, '.') + 1)) == 'png')
  15. {
  16. return $file . PHP_EOL;
  17. }
  18. }
  19. closedir($handle);
  20. }
  21. else
  22. {
  23. print("\nERROR! Can't find directory!\n");
  24. }
  25. }
  26. else
  27. {
  28. print("\nERROR! Parameter isn't a directory!\n");
  29. }
  30. }
  31.  
  32. // my_scan_dir("./");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement