Reputation: 59
If I had a code like, if ($_REQUEST['carrier'] == "T-Mobile") {}
could I not have to do "t-mobile"
as well if someone for example, forgets to capitalize they're carrier name? I am writing an email text subscription system.
Upvotes: 0
Views: 161
Reputation: 6018
if (strtolower($_REQUEST['carrier']) == "t-mobile") { /* ... */ }
There are more elegant ways to do it, but you get the idea.
Upvotes: 0
Reputation: 658
You can use the strcasecmp function to check if the two strings are equal (case insensitive).
If they are equal, this function returns 0.
Take a look here: http://php.net/manual/en/function.strcasecmp.php
Your if would look like this
if (strcasecmp($_REQUEST['carrier'], "T-Mobile") == 0)
Upvotes: 1
Reputation: 28316
Yes, it's case sensitive. The solution is to convert the input to lowercase:
if (strtolower($_REQUEST['carrier']) == "t-mobile") {
Upvotes: 0
Reputation: 3656
I cant' really figure out your question but...
Try to convert both to lower case and compare thusly.
Upvotes: 0