src/Library/Helper/Filesystem.php
public static function resolveRelatedPath($from, $to)
    {
        $from_parts = array_filter( explode('/', $from) );
        $to_parts = array_filter( explode('/', $to) );
        foreach($from_parts as $i=>$path) {
            if (in_array($path, $to_parts)) {
                $from_parts[$i] = null;
                $to_parts[$i] = null;
            }
        }
        $from_parts = array_filter($from_parts);
        $to_parts = array_filter($to_parts);
        for($i=0; $i<count($from_parts); $i++) {
            array_unshift($to_parts, '..');
        }
/*
        foreach($from_parts as $path) {
            array_unshift($to_parts, $path);
        }
*/
        return join('/', $to_parts);
    }
public static function resolveRelatedPath($from, $to)
    {
        $from_parts = array_filter( explode('/', $from) );
        $to_parts = array_filter( explode('/', $to) );
        foreach($from_parts as $i=>$path) {
            if (in_array($path, $to_parts)) {
                $from_parts[$i] = null;
                $to_parts[$i] = null;
            }
        }
        $from_parts = array_filter($from_parts);
        $to_parts = array_filter($to_parts);
        for($i=0; $i<count($from_parts); $i++) {
            array_unshift($to_parts, '..');
        }
/*
        foreach($from_parts as $path) {
            array_unshift($to_parts, $path);
        }
*/
        return join('/', $to_parts);
    }
public static function resolveRelatedPath ( $ from , $ to ) { $ from_parts = array_filter ( explode ( '/' , $ from ) ) ; $ to_parts = array_filter ( explode ( '/' , $ to ) ) ; foreach ( $ from_parts as $ i => $ path ) { if ( in_array ( $ path , $ to_parts ) ) { $ from_parts [ $ i ] = null ; $ to_parts [ $ i ] = null ; } } $ from_parts = array_filter ( $ from_parts ) ; $ to_parts = array_filter ( $ to_parts ) ; for ( $ i = 0 ; $ i < count ( $ from_parts ) ; $ i ++ ) { array_unshift ( $ to_parts , '..' ) ; } /*
        foreach($from_parts as $path) {
            array_unshift($to_parts, $path);
        }
*/ return join ( '/' , $ to_parts ) ; }
Returns a relative path between two filesystem realpaths

@param   string  $from   The absolute path to work from
@param   string  $to     The absolute path to resolve from `$from`
@return  string  The relative path from `$from` to `$to`
Returns a relative path between two filesystem realpaths