PHP code example of okapi / path

1. Go to this page and download the library: Download okapi/path library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

okapi / path example snippets




use Okapi\Path\Path;

// Resolve

$path = Path::resolve('./path/to/file.txt');
// --> /project/path/to/file.txt

$path = Path::resolve([
    './path/to/file.txt',
    '../project2/file.txt',
]);
// [0] --> /project/path/to/file.txt
// [1] --> /project2/file.txt



// Join

$path = Path::join('/project', 'path', 'to', 'file.txt');
// --> /project/path/to/file.txt