Oihana PHP

computeRelativePath.php

Table of Contents

Functions

computeRelativePath()  : string
Computes the relative path between two normalized relative paths.

Functions

computeRelativePath()

Computes the relative path between two normalized relative paths.

computeRelativePath(string $targetPath, string $basePath) : string
Parameters
$targetPath : string

The target relative path.

$basePath : string

The base relative path.

Tags
example
echo computeRelativePath( 'foo/bar/baz' , 'foo'     ) . PHP_EOL; // 'bar/baz'
echo computeRelativePath( 'foo/baz'     , 'foo/bar' ) . PHP_EOL; // '../baz'
echo computeRelativePath( 'foo/bar'     , 'foo/bar' ) . PHP_EOL; // '.'
echo computeRelativePath( 'a/b'         , 'a/b/c/d' ) . PHP_EOL; // '../../'
echo computeRelativePath( 'a/b/c'       , 'a'       ) . PHP_EOL; // 'b/c'
echo computeRelativePath( 'a/x/y'       , 'a/b/c'   ) . PHP_EOL; // '../../x/y'
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

The relative path from base to target.


        
On this page

Search results