Page 1 of 1

lettercase

Posted: Wed Oct 06, 2010 6:56 am
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..

Re: lettercase

Posted: Wed Oct 06, 2010 6:59 am
by amargharat
check as follows,

Code: Select all

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

}

Re: lettercase

Posted: Wed Oct 06, 2010 8:10 am
by Anant
thanks - this works.

Re: lettercase

Posted: Wed Oct 06, 2010 8:26 am
by requinix
Or you could use a function that exists for this exact situation.

Code: Select all

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