PHP code example of sledgehammer / filters

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

    

sledgehammer / filters example snippets


$encoded = filter($myData, 'urlencode'); // Using a global function.

$db = new PDO('sqlite::memory:');
$quoted = filter($myData, array($db, 'quote')); // Using a function in a object/class.

$slug = filter($myData, new SlugFilter()); /// Using a object with an __invoke() method.

$filter = function ($data) { return substr($data, 0, 10); };
$truncated = filter($myData, $filter); // Using a closure.