Posted By

Mikaye on 05/18/10


Tagged

path relative


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


Find relative path to a specific file


 / Published in: PHP
 

  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  

You need to login to post a comment.