Posted By

iloveitaly on 08/31/09


Tagged

php file path standard FileSystem slash normalize


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Normalize File Path PHP


 / Published in: PHP
 

  1. function normalize_path($path, $with_slash = true) {
  2. if($path[0] == DIRECTORY_SEPARATOR)
  3. if($with_slash) return $path;
  4. else return substr($path, 1);
  5. else
  6. if($with_slash) return DIRECTORY_SEPARATOR.$path;
  7. else return $path;
  8. }

Report this snippet  

You need to login to post a comment.