public static function resolveRelative($sourcePath, $targetPath)
    {
        if ('.' == dirname($sourcePath)) {
            $path = str_repeat('../', substr_count($targetPath, '/'));
        } elseif ('.' == $targetDir = dirname($targetPath)) {
            $path = dirname($sourcePath).'/';
        } else {
            $path = '';
            while (0 !== strpos($sourcePath, $targetDir)) {
                if (false !== $pos = strrpos($targetDir, '/')) {
                    $targetDir = substr($targetDir, 0, $pos);
                    $path .= '../';
                } else {
                    $targetDir = '';
                    $path .= '../';
                    break;
                }
            }
            $path .= ltrim(substr(dirname($sourcePath).'/', strlen($targetDir)), '/');
        }

        return $path;
    }
public static function resolveRelative($sourcePath, $targetPath)
    {
        if ('.' == dirname($sourcePath)) {
            $path = str_repeat('../', substr_count($targetPath, '/'));
        } elseif ('.' == $targetDir = dirname($targetPath)) {
            $path = dirname($sourcePath).'/';
        } else {
            $path = '';
            while (0 !== strpos($sourcePath, $targetDir)) {
                if (false !== $pos = strrpos($targetDir, '/')) {
                    $targetDir = substr($targetDir, 0, $pos);
                    $path .= '../';
                } else {
                    $targetDir = '';
                    $path .= '../';
                    break;
                }
            }
            $path .= ltrim(substr(dirname($sourcePath).'/', strlen($targetDir)), '/');
        }

        return $path;
    }
public static function resolveRelative ( $ sourcePath , $ targetPath ) { if ( '.' == dirname ( $ sourcePath ) ) { $ path = str_repeat ( '../' , substr_count ( $ targetPath , '/' ) ) ; } elseif ( '.' == $ targetDir = dirname ( $ targetPath ) ) { $ path = dirname ( $ sourcePath ) . '/' ; } else { $ path = '' ; while ( 0 !== strpos ( $ sourcePath , $ targetDir ) ) { if ( false !== $ pos = strrpos ( $ targetDir , '/' ) ) { $ targetDir = substr ( $ targetDir , 0 , $ pos ) ; $ path .= '../' ; } else { $ targetDir = '' ; $ path .= '../' ; break ; } } $ path .= ltrim ( substr ( dirname ( $ sourcePath ) . '/' , strlen ( $ targetDir ) ) , '/' ) ; } return $ path ; }
Returns relative path to the source directory from the target path.

@return string
Returns relative path to the source directory from the target path .