Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Retrieve whitelisted set of parameters
<?php
function filter_params(array $params = [], array $whitelist = []) {
return array_map('trim', array_intersect_key($params, array_flip($whitelist)));
}
$params = ['is_admin' => 1, 'name' => ' Bob', 'surname' => 'Smith '];
$whitelist = ['name', 'surname'];
// these are your whitelisted parameters (please don't forget to filter/validate before persisting)
var_dump(filter_params($params, $whitelist));
<?php
function filter_params(array $params = array(), array $whitelist = array()) {
return array_map('trim', array_intersect_key($params, array_flip($whitelist)));
}
$params = array('is_admin' => 1, 'name' => ' Bob', 'surname' => 'Smith ');
$whitelist = array('name', 'surname');
// these are your whitelisted parameters (please don't forget to filter/validate before persisting)
var_dump(filter_params($params, $whitelist));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.