src/Path.php
/**
     * Return relative path from a given file or directory to another location.
     *
     * @param string $from      the path of departure file or directory
     * @param string $to        the path of destination file or directory
     * @param string $separator the directory separator want to use in the result
     *
     * @return string
     */
Return relative path from a given file or directory to another location.
@param string $from      the path of departure file or directory
@param string $to        the path of destination file or directory
@param string $separator the directory separator want to use in the result

@return string
Return relative path from a given file or directory to another location . @param string $from the path of departure file or directory @param string $to the path of destination file or directory @param string $separator the directory separator want to use in the result @return string
public static function relative($from, $to, $separator = DIRECTORY_SEPARATOR)
    {
        $separator  = $separator ?: DIRECTORY_SEPARATOR;
        $fromParts  = explode($separator, static::absolute($from, $separator));
        $toParts    = explode($separator, static::absolute($to, $separator));
        $diffFromTo = array_diff_assoc($fromParts, $toParts);
        $diffToFrom = array_diff_assoc($toParts, $fromParts);
        if ($diffToFrom === $toParts) {
            return implode($separator, $toParts);
        }
        return str_repeat('..' . $separator, count($diffFromTo)) . implode($separator, $diffToFrom);
    }
public static function relative ( $ from , $ to , $ separator = DIRECTORY_SEPARATOR ) { $ separator = $ separator ? : DIRECTORY_SEPARATOR ; $ fromParts = explode ( $ separator , static :: absolute ( $ from , $ separator ) ) ; $ toParts = explode ( $ separator , static :: absolute ( $ to , $ separator ) ) ; $ diffFromTo = array_diff_assoc ( $ fromParts , $ toParts ) ; $ diffToFrom = array_diff_assoc ( $ toParts , $ fromParts ) ; if ( $ diffToFrom === $ toParts ) { return implode ( $ separator , $ toParts ) ; } return str_repeat ( '..' . $ separator , count ( $ diffFromTo ) ) . implode ( $ separator , $ diffToFrom ) ; }
Return relative path from a given file or directory to another location.
Return relative path from a given file or directory to another location .