PHP code example of flatphp / sanitization

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

    

flatphp / sanitization example snippets


use \Flatphp\sanitization\sanitizer;

// sanitize one
$value = Sanitizer::sanitizeOne(' hello ', 'trim|upper');


// sanitize all
$data = [
    'v1' => '10.0',
    'v2' => ['a', 'b', 'c'],
    'v3' => ' hello '
];
$data = Sanitizer::sanitize($data, array(
    'v1' => 'int',
    'v2' => 'string:,|upper',
    'v3' => function($value){
        return strtoupper(trim($value));
    }
));


// just use single
$value = Sanitizer::toArray('1,2,3', ',');