PHP code example of siriusphp / filtration
1. Go to this page and download the library: Download siriusphp/filtration 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/ */
siriusphp / filtration example snippets
use Sirius\Filtration\Filtrator;
$filtrator = new Filtrator();
// add filters for title
$filtrator->add('title', 'trim');
$filtrator->add('title', 'strip_tags');
$filtrator->add('title', 'nullify');
// add filters for content in one go
$filtrator->add('content', [
'trim'
]);
$result = $filtrator->filter(array(
'title' => ' <h1>My title has tags and is awesome</h1>',
'content' => ' My content was trimmed'
));
/* $result is
array(
'title' => NULL ,
'content' => 'My content was trimmed'
)
*/