public static function calculate_relative_path($file, $returnDir = false)
    {
        // We find the document root of the webserver
        $doc_root = $_SERVER['DOCUMENT_ROOT'];

        // Remove the document root, from the FULL absolute path of the
        // file we're looking for
        $ret = "/" . str_replace($doc_root, "", $file, $ok);
        if (!$ok) {
            return false;
        }

        // If they want the path to the dir, only return the dir part
        if ($returnDir) {
            $ret = dirname($ret) . "/";
        }

        $ret = preg_replace("|//|", "/", $ret);

        return $ret;
    }
public static function calculate_relative_path($file, $returnDir = false)
    {
        // We find the document root of the webserver
        $doc_root = $_SERVER['DOCUMENT_ROOT'];

        // Remove the document root, from the FULL absolute path of the
        // file we're looking for
        $ret = "/" . str_replace($doc_root, "", $file, $ok);
        if (!$ok) {
            return false;
        }

        // If they want the path to the dir, only return the dir part
        if ($returnDir) {
            $ret = dirname($ret) . "/";
        }

        $ret = preg_replace("|//|", "/", $ret);

        return $ret;
    }
public static function calculate_relative_path ( $ file , $ returnDir = false ) { // We find the document root of the webserver $ doc_root = $ _SERVER [ 'DOCUMENT_ROOT' ] ; // Remove the document root, from the FULL absolute path of the // file we're looking for $ ret = "/" . str_replace ( $ doc_root , "" , $ file , $ ok ) ; if ( ! $ ok ) { return false ; } // If they want the path to the dir, only return the dir part if ( $ returnDir ) { $ ret = dirname ( $ ret ) . "/" ; } $ ret = preg_replace ( "|//|" , "/" , $ ret ) ; return $ ret ; }
Calculate the relative path of a given absolute URL

@return string
@access public
@static
@param $file string The file to calculate the relative path of
@param $returnDir bool If set to true, only return the dirname
Calculate the relative path of a given absolute URL