Any case(both upper and lower case)

if ($myVar ===  'ab' OR $myVar ===  'aB' OR myVar ===  'Ab' OR myVar=== 'AB') {
} 

I have a condition code like the above.
I like to change the condition code above to the would-be condition code below.
Although the would-be code below doesn’t work correctly, I hope it shows what I want.

if ( upper_OR_lowerCase($myVar) === 'ab') {
}

Because the number of alphabet of $myVar is only 2, I can make the condition code above with “3 ORs”…
However, if the number of alphabet of $myVar is 3, then I might need 16 ORs.in the condition.
and if the number of alphabet of $myVar more than 3, then I need many many ORs in the condition.

The PHP manual is full of wonderful information: strtolower.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.