Normalize File Path PHP


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.