PHP code example of cpsit / glob

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

    

cpsit / glob example snippets


use CPSIT\Glob\Glob;

$paths = Glob::glob('/path/to/dir/*.css'); 

use CPSIT\Glob\Iterator\GlobIterator;

$iterator = new GlobIterator('/path/to/dir/*.css');

foreach ($iterator as $path) {
    // ...
}

if (Glob::match($path, '/path/to/dir/*.css')) {
    // ...
}

$paths = Glob::filter($paths, '/path/to/dir/*.css');

use CPSIT\Glob\Iterator\GlobFilterIterator;

$iterator = new GlobFilterIterator('/path/to/dir/*.css', new ArrayIterator($paths));

foreach ($iterator as $path) {
    // ...
}

$paths = Glob::filter($paths, '/path/to/dir/*.css', Glob::FILTER_KEY);

$iterator = new GlobFilterIterator(
    '/path/to/dir/*.css', 
    new ArrayIterator($paths),
    GlobFilterIterator::FILTER_KEY
);

use CPSIT\Glob\Glob;
use Webmozart\PathUtil\Path;

// If $glob is absolute, that glob is used without modification.
// If $glob is relative, it is turned into an absolute path based on the current
// working directory.
$paths = Glob::glob(Path::makeAbsolute($glob, getcwd());

$paths = Glob::glob('/backup\\*/*.css');

$paths = Glob::glob('myscheme:///**/*.css');