Return to Snippet

Revision: 39534
at January 18, 2011 04:36 by kendsnyder


Initial Code
// from http://kendsnyder.com/posts/pathconcat
function pathConcat(/*path1, $path2[, $path3][, $pathN]*/) {
  $parts = func_get_args();
  $base = array_shift($parts);
  $base = str_replace('\/',"\x01",$base);
  $base = rtrim($base, '/');
  $paths = array();
  foreach ($parts as $part) {
    $part = str_replace('\/',"\x01",$part);
    $part = trim($part, '/');
    if (strlen($part)) {
      $paths[] = $part;
    }
  }
  $fullpath = join($paths, '/');
  $fullpath = $base . '/' . $fullpath; 
  $fullpath = str_replace("\x01",'\/',$fullpath);
  return $fullpath;
}

Initial URL


Initial Description


Initial Title
Concatenate file paths

Initial Tags
file

Initial Language
PHP