I have a string like
"Geräumiges Studentenapartment in Aachens Fußgängerzone am Aquis Plaza!"
I want to remove the special character form the string. i have already used strip_tags and htmlspecialchars for this. but did not work.
I have a string like
"Geräumiges Studentenapartment in Aachens Fußgängerzone am Aquis Plaza!"
I want to remove the special character form the string. i have already used strip_tags and htmlspecialchars for this. but did not work.
You can use preg_replace
to remove these special characters.
For example:
$output=preg_replace('/[^(\x20-\x7f)]*/s','',$string);
Something like
function clean($string) {
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
Usage:
echo clean('a|"bc!@£de^&$f g');
output:
abcdef-g