I imagine I need to remove chars 0-31 and 127,
Is there a function or piece of code to do this efficiently.
I imagine I need to remove chars 0-31 and 127,
Is there a function or piece of code to do this efficiently.
You could use a regular express to remove everything apart from those characters you wish to keep:
$string=preg_replace('/[^A-Za-z0-9 _\-\+\&]/','',$string);
Replaces everything that is not (^) the letters A-Z or a-z, the numbers 0-9, space, underscore, hypen, plus and ampersand - with nothing (i.e. remove it).
Something like this should do it
$string = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $string);
It matches anything in range 0-31, 128-255 and removes it.