PHP code example of ashleydawson / globtoregex

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

    

ashleydawson / globtoregex example snippets




x = \AshleyDawson\GlobToRegex\glob_to_regex('/**/*.txt');

echo $regex;



unction AshleyDawson\GlobToRegex\glob_to_regex;

$paths = [
    '/foo/bar/sample.txt', 
    '/baz/biz/example.txt', 
    '/fiz/boo/music.mp3',
];

// Find matches for the glob pattern `/**/*.txt`
$regex = glob_to_regex('/**/*.txt');

$matches = array_filter($paths, function ($path) use ($regex) {
    return preg_match($regex, $path);
});

print_r($matches);