src/Builder.php
protected function relativeUrl($from='', $to='')
    {
        $from = explode('/', ltrim($from, '/'));
        $to   = explode('/', ltrim($to, '/'));
        $last = false;
        while (count($from) && count($to) && $from[0] === $to[0]) {
            $last = array_shift($from);
            array_shift($to);
        }
        if (count($from) == 0) {
            if ($last) array_unshift($to, $last);
            return './' . implode('/', $to);
        }
        else {
            return './' . str_repeat('../', count($from)-1) . implode('/', $to);
        }
    }
protected function relativeUrl($from='', $to='')
    {
        $from = explode('/', ltrim($from, '/'));
        $to   = explode('/', ltrim($to, '/'));
        $last = false;
        while (count($from) && count($to) && $from[0] === $to[0]) {
            $last = array_shift($from);
            array_shift($to);
        }
        if (count($from) == 0) {
            if ($last) array_unshift($to, $last);
            return './' . implode('/', $to);
        }
        else {
            return './' . str_repeat('../', count($from)-1) . implode('/', $to);
        }
    }
protected function relativeUrl ( $ from = '' , $ to = '' ) { $ from = explode ( '/' , ltrim ( $ from , '/' ) ) ; $ to = explode ( '/' , ltrim ( $ to , '/' ) ) ; $ last = false ; while ( count ( $ from ) && count ( $ to ) && $ from [ 0 ] === $ to [ 0 ] ) { $ last = array_shift ( $ from ) ; array_shift ( $ to ) ; } if ( count ( $ from ) == 0 ) { if ( $ last ) array_unshift ( $ to , $ last ) ; return './' . implode ( '/' , $ to ) ; } else { return './' . str_repeat ( '../' , count ( $ from ) - 1 ) . implode ( '/' , $ to ) ; } }
Build a relative URL from one absolute path to another,
going back as many times as needed. Paths should be absolute
or are considered to be starting from the same root.
@param string $from
@param string $to
@return string
Build a relative URL from one absolute path to another going back as many times as needed . Paths should be absolute or are considered to be starting from the same root .