Posted By

luman on 12/30/08


Tagged

file rename exist


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

not_skeletor
fackz
luctus


Check file exists and rename


 / Published in: PHP
 

URL: http://es2.php.net/manual/en/function.file-exists.php#60458

  1. function imageExists($image,$dir) {
  2.  
  3. $i=1; $probeer=$image;
  4.  
  5. while(file_exists($dir.$probeer)) {
  6. $punt=strrpos($image,".");
  7. if(substr($image,($punt-3),1)!==("[") && substr($image,($punt-1),1)!==("]")) {
  8. $probeer=substr($image,0,$punt)."[".$i."]".
  9. substr($image,($punt),strlen($image)-$punt);
  10. } else {
  11. $probeer=substr($image,0,($punt-3))."[".$i."]".
  12. substr($image,($punt),strlen($image)-$punt);
  13. }
  14. $i++;
  15. }
  16. return $probeer;
  17. }

Report this snippet  

You need to login to post a comment.