Find relative path to a specific file


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function Path($file) {
  2. if(file_exists($file)) {
  3. return "./$file";
  4. }else {
  5. $Path="..";
  6. while(true) {
  7. if(file_exists($Path.'/'.$file)) return $Path."/$file";
  8. $Path.="/..";
  9. }
  10. }
  11.  
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.