Looking for a function that cleans a string of bad chars and words

Hi,

I am looking for a nifty little Php function that checks a string and returns True if it is made up of Letters and Numbers only
and otherwise it returns False.

And also a function that looks at a string and replaces any occurrences of (‘xyz’, ‘yzx’, etc.) in that string with a selected string such as ***

FYI: So this way we can only allow Nicknames that are made up of Letters and Numbers and have no swear or bad words in them.

Regards,

See PHP: ctype_alnum - Manual for how to test for alphanumeric only.

To do your replaces you could use regular expressions - see PHP: preg_replace - Manual

For replacing the bad words I’d use [fphp]strtr[/fphp], although I wouldn’t replace bad words in usernames, but simply refuse that input. If you change that you get conversations between *** , *** (which is actually another person who happened to use a bad word that was also three characters long), ****, **** (also another person), **** (yet another person), etc, etc, …