manix Posted October 30, 2011 Share Posted October 30, 2011 I have this $str variable which say holds "String" and in my comparison I'm checking if it's content is "string" and it is supposed to return true but it isnt because of the case, how do I compare them without the case being an issue ? Quote Link to comment https://forums.phpfreaks.com/topic/250105-string-comparison-case/ Share on other sites More sharing options...
MasterACE14 Posted October 30, 2011 Share Posted October 30, 2011 you could just convert both strings to lower or upper case on the fly: $str = 'String'; if(strtolower($str) == 'string') { echo "The Same"; } else { echo "Not the Same"; } Quote Link to comment https://forums.phpfreaks.com/topic/250105-string-comparison-case/#findComment-1283436 Share on other sites More sharing options...
manix Posted October 30, 2011 Author Share Posted October 30, 2011 kinda saw that comming .. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/250105-string-comparison-case/#findComment-1283438 Share on other sites More sharing options...
Pikachu2000 Posted October 30, 2011 Share Posted October 30, 2011 Or use strcasecmp. Quote Link to comment https://forums.phpfreaks.com/topic/250105-string-comparison-case/#findComment-1283442 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.