PHP code example of czproject / path-helper

1. Go to this page and download the library: Download czproject/path-helper 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/ */

    

czproject / path-helper example snippets

 php
PathHelper::absolutizePath($path);

PathHelper::absolutizePath('path/to/my/../text/./file.txt');
 php
$source = 'root/dir/docs/1.0/index.html';
$dest = 'root/dir/imgs/image.jpg';

PathHelper::createRelativePath($source, $dest);
 php
PathHelper::isPathCurrent($path, $mask);

PathHelper::isPathCurrent('dir/file.txt', 'dir/file-2.txt'); // returns FALSE
PathHelper::isPathCurrent('dir/file.txt', 'dir/*'); // returns TRUE
PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/*'); // returns FALSE
PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/*/*'); // returns TRUE
PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/**'); // returns TRUE
 php
PathHelper::normalizePath($path);

PathHelper::normalizePath('\\path\\to\\file.txt');