lettercase

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
Anant
Forum Commoner
Posts: 66
Joined: Wed Jul 14, 2010 11:46 am

lettercase

Post by Anant »

There is a situation where am cross checking the info that user enters with that in our database.
basically - -

Code: Select all

if($row['userValue'] == $dataValue)
{
}

but i don't want any sort of letter case issue. At the moment if the dataValue is "Apple" and user enters "apple" -- it gives error.

I know it's pretty simple but am not sure about the syntax.

Thank you..
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: lettercase

Post by amargharat »

check as follows,

Code: Select all

if(strtolower($row["user"]) == strtolower($userValue))
{

}
Anant
Forum Commoner
Posts: 66
Joined: Wed Jul 14, 2010 11:46 am

Re: lettercase

Post by Anant »

thanks - this works.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: lettercase

Post by requinix »

Or you could use a function that exists for this exact situation.

Code: Select all

if (strcasecmp($row["user"], $userValue) == 0) {
Post Reply