Page 1 of 1

Case SpEcIfIc

Posted: Mon Dec 09, 2002 11:32 pm
by oldtimer
Okay. I am using explode to go through a post to check for cuss words. How can you check with out being case specific. As you know there are many combos for a 3 letter word. If it helps you I will be inserting these words in lowercase cuss words into a database.

Jerry

Posted: Tue Dec 10, 2002 6:00 am
by riley
http://www.php.net/manual/en/function.strcasecmp.php

Code: Select all

strcasecmp
(PHP 3>= 3.0.2, PHP 4 )

strcasecmp --  Binary safe case-insensitive string comparison 
Description
int strcasecmp ( string str1, string str2)


Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. Example 1. strcasecmp() example

$var1 = "Hello";
$var2 = "hello";
if (!strcasecmp($var1, $var2)) &#123;
    echo '$var1 is equal to $var2 in a case-insensitive string comparison';
&#125;

Posted: Tue Dec 10, 2002 1:17 pm
by oldtimer
AT first I did not understand this but then it made sense. However before it made sense I just made the whlo string lowercase and then checked it. However I left the original string alone. Just did $one=($two); and then $words = strtolower($one); Works great. Now on to taking out extra spaces so the $words=explode(" ",$words); dont mess up.