PHP code example of accentinteractive / disallowlister
1. Go to this page and download the library: Download accentinteractive/disallowlister 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/ */
accentinteractive / disallowlister example snippets
// Pass the disallowlist in the constructor
$disallowLister = new DisallowLister(['foo']); // ['foo']
// Set the disallowlist in the setter method
$disallowLister->setDisallowList(['bar']); // ['bar']
// Add an item to the disallowlist
$disallowLister->add('baz'); // ['bar', 'baz']
// Add multiple items to the disallowlist
$disallowLister->add(['bat', 'fiz']); // ['bar', 'baz', 'bat', 'fiz']
// Remove an item from the disallowlist
$disallowLister->remove('fiz'); // ['bar', 'baz', 'bat']
// Remove multiple items from the disallowlist
$disallowLister->remove(['baz', 'bat']); // ['bar']
## Literal string
$disallowLister = new DisallowLister(['bar', 'foo']);
$disallowLister->isDisallowed('bar'); // Returns true
$disallowLister->isDisallowed('bars'); // Returns false
## Wildcards
// Under the hood, `accentinteractive/disallowtester`
// uses `fnmatch()`, so you can use the same
// wildcards as in that php function (the
// globbing wildcard patterns):
(new DisallowLister(['b?r']))->isDisallowed('bar'); // Returns true
(new DisallowLister(['m[o,u]m']))->isDisallowed('mom'); // Returns true
(new DisallowLister(['*bar*']))->isDisallowed('I like crowbars'); // Returns true
// By default, matching is not case sensitive
(new DisallowLister(['bar']))->isDisallowed('BAR'); // Returns true
// To set case sensitive matching
(new DisallowLister(['bar']))->caseSensitive(true)->isDisallowed('BAR'); // Returns false
// By default the entire string is checked.
(new DisallowLister())->setDisallowList(['bar'])->isDisallowed('My favorite bar'); // Returns false
// Check word for word.
(new DisallowLister())->setDisallowList(['bar'])->setWordForWord(true)->isDisallowed('My favorite bar'); // Returns true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.