PHP code example of objective-php / matcher

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

    

objective-php / matcher example snippets


$id1 = 'key'; // root level key
$id2 = 'section.key'; // namespaced section
$id3 = 'section.sub-section.key'; // multi-level namespaced key
$id4 = 'section.other-sub-section.key'; // other multi-level namespaced key

$matcher = new Matcher();

$matcher->match('engine.extensions.load', 'engine.extensions.load'); // returns TRUE, of course
$matcher->match('engine.extensions.load', 'engine.?.load'); // also returns TRUE
$matcher->match('engine.resource.load', 'engine.?.load'); // returns TRUE as well
$matcher->match('engine.extensions.load', '?.load'); // returns FALSE, since the question mark only replaces one section!
$matcher->match('engine.extensions.load', '*.load'); // returns TRUE, since the star replaces any number of sections sections!

$matcher->match('engine.extensions.load', 'engine.[extensions|resource].load'); // also returns TRUE
$matcher->match('engine.resource.load', 'engine.[extensions|resource].load'); // returns TRUE as well
$matcher->match('engine.service.load', 'engine.[extensions|resource].load'); // this one returns FALSE