- filter_var: documentation ( source)
- trim: documentation ( source)
- preg_replace: documentation ( source)
<?php
$fullName = 'Foo!"bar" Baz ΓΈ hello!<strong>poop</strong>';
$fullName = filter_var($fullName, FILTER_CALLBACK, ['options'=>function($value) {
$value = trim($value);
// strip tags
$value = filter_var($value, FILTER_SANITIZE_STRING);
// remove double quotes
$value = preg_replace('/["<>\{\}\[\]]+/', '', $value);
return $value;
}]);
echo "$fullName\n";