Restrict characters used in a string
- by Jeremy Rudd
How do I restrict a string to whitelisted characters?
// "HOW am I to understand; this is, BAD"
$str = restrictTo($str,"0-9a-z,. ");
// " am I to understand this is, "
Is there an inbuilt function in PHP that does something close? I can't formulate a regular expression for this though :(