PHP code example of vmexanik / filterlinkgenerator

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

    

vmexanik / filterlinkgenerator example snippets




use FilterLinkGenerator\FilterLinkGenerator;

$template = "/my-project/{my-filter={\$param}/}";

$data = [
    'param' => [
        'data' => [
            'first_param',
            'second_param',
            'third_param'
        ],
        'selected' => [
            'second_param'
        ],
        'separator' => '_'
    ]
];

$filterLinks = new FilterLinkGenerator($template, $data);

$generatedLinks = $filterLinks->generateLink()


Array
(
    [param] => Array
        (
            [first_param] => /my-project/my-filter=second_param_first_param/
            [second_param] => /my-project/
            [third_param] => /my-project/my-filter=second_param_third_param/
        )

)