Case SpEcIfIc

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Case SpEcIfIc

Post 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
User avatar
riley
Forum Commoner
Posts: 45
Joined: Thu May 02, 2002 6:31 pm

Post 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;
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post 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.
Post Reply