Re: Checking a strings case
| From: | David Robley | Date: | Tue, 15 Apr 2003 08:47:26 +0000 |
| Subject: | Re: Checking a strings case | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143884@lists.php.net to get a copy of this message | ||
In article <000701c30310$889ee2a0$6401a8c0@p1>, odcs@rogers.com says...
> I'm trying to create a function to check a users input for "foul" language
> and want to be able to check variations of case (i.e. CasE or cAsE). I have
> checked out all the ereg and str* functions but not quite sure how to do
> this. These "foul" words are in an array. I have it working now if a user
> inputs 'case' or 'CASE'.
>
> TIA
strtoupper() or strtolower() are possibly your friends. Something along
the lines of the following will catch all variations.
$badwords = array ("poo","bum","wee","bugger") ; //all lower
case
if(in_array(strtolower($word_to_check))) {
echo "Bad person - you used a naughty word";
}
Cheers
--
Quod subigo farinam
$email =~ s/oz$/au/o;