$dir) /* Each ``$from`` directory. */ { if (isset ($to[$depth]) && $dir === $to[$depth]) array_shift($rel_path); /**/ else if (($remaining = count ($from) - $depth) > 1) { $rel_path = array_pad ($rel_path, ((count ($rel_path) + $remaining - 1) * -1), ".."); break; /* Stop now, no need to go any further. */ } else $rel_path[0] = "./" . $rel_path[0]; } } /**/ return implode ("/", $rel_path); } /** * Shortens to a path from document root. * * @package s2Member\Utilities * @since 110815 * * @param str $path Directory or file path. * @return str Shorther path, from document root. */ public static function doc_root_path ($path = FALSE) { return preg_replace ("/^" . preg_quote (rtrim ($_SERVER["DOCUMENT_ROOT"], DIRECTORY_SEPARATOR . "/"), "/") . "/", "", (string)$path); } } } ?>