PHP code example of ptrofimov / matchmaker

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

    

ptrofimov / matchmaker example snippets


$books = [
    [
        'type' => 'book',
        'title' => 'Geography book',
        'chapters' => [
            'eu' => ['title' => 'Europe', 'interesting' => true],
            'as' => ['title' => 'America', 'interesting' => false]
        ]
    ],
    [
        'type' => 'book',
        'title' => 'Foreign languages book',
        'chapters' => [
            'de' => ['title' => 'Deutsch']
        ]
    ]
];

$pattern = [
    '*' => [
        'type' => 'book',
        'title' => ':string contains(book)',
        'chapters' => [
            ':string length(2) {1,3}' => [
                'title' => ':string',
                'interesting?' => ':bool',
            ]
        ]
    ]
];

matchmaker\matches($books, $pattern); // true