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 ? 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"; } 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! 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. Link to comment https://forums.phpfreaks.com/topic/250105-string-comparison-case/#findComment-1283442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.