public static function pathToRel($path): string
    {
        $root = FS::clean(Vars::get($_SERVER['DOCUMENT_ROOT']));
        $path = FS::clean($path);

        $normRoot = str_replace(DIRECTORY_SEPARATOR, '/', $root);
        $normPath = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        $regExp = '/^' . preg_quote($normRoot, '/') . '/i';
        $relative = preg_replace($regExp, '', $normPath);

        $relative = ltrim($relative, '/');

        return $relative;
    }
public static function pathToRel($path): string
    {
        $root = FS::clean(Vars::get($_SERVER['DOCUMENT_ROOT']));
        $path = FS::clean($path);

        $normRoot = str_replace(DIRECTORY_SEPARATOR, '/', $root);
        $normPath = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        $regExp = '/^' . preg_quote($normRoot, '/') . '/i';
        $relative = preg_replace($regExp, '', $normPath);

        $relative = ltrim($relative, '/');

        return $relative;
    }
public static function pathToRel ( $ path ) : string { $ root = FS :: clean ( Vars :: get ( $ _SERVER [ 'DOCUMENT_ROOT' ] ) ) ; $ path = FS :: clean ( $ path ) ; $ normRoot = str_replace ( DIRECTORY_SEPARATOR , '/' , $ root ) ; $ normPath = str_replace ( DIRECTORY_SEPARATOR , '/' , $ path ) ; $ regExp = '/^' . preg_quote ( $ normRoot , '/' ) . '/i' ; $ relative = preg_replace ( $ regExp , '' , $ normPath ) ; $ relative = ltrim ( $ relative , '/' ) ; return $ relative ; }
Convert file path to relative URL

@param $path
@return string

@SuppressWarnings(PHPMD.Superglobals)
Convert file path to relative URL