realjumper Posted September 5, 2006 Share Posted September 5, 2006 Hi,According to the manual this should work.......[code]<?php $a = 'a'; $b = 'A';if (strcasecmp($a, $b) == 0) { echo '$a is equal to $b in a case-insensitive string comparison';}[/code]If I comment out the 'echo.....' the page displays. With the echo in place nothing displays, and I don't know why.All I am tring to do is to (utimately) have $a equal $b when $a might be in caps and $b might be in lower case. I wish to return True that $a equals $b regardless of case. I'm sure I have used this before but I can't find the code in my library. Can anyone help? Link to comment https://forums.phpfreaks.com/topic/19832-case-sensitive-problem/ Share on other sites More sharing options...
realjumper Posted September 5, 2006 Author Share Posted September 5, 2006 Never mind...I've figured it out Link to comment https://forums.phpfreaks.com/topic/19832-case-sensitive-problem/#findComment-86790 Share on other sites More sharing options...
AndyB Posted September 5, 2006 Share Posted September 5, 2006 ... and for the benegit of the rest of us, the solution was ... Link to comment https://forums.phpfreaks.com/topic/19832-case-sensitive-problem/#findComment-86791 Share on other sites More sharing options...
realjumper Posted September 6, 2006 Author Share Posted September 6, 2006 The solution was.....(I was getting to the post ;))That this piece of code returns '0' if the comparison is true.....[code]<?php$a = 'a';$b = 'A';echo strcasecmp("$a","$b");?>[/code]The above returns '0'. So.....[code]<?php$a = 'a'; $b = 'b';$compare = strcasecmp("$a","$b");if ($compare == '0'){ Header("Location: yipee_you_are_logged_in.php"); exit();}?>[/code]$compare DOES equal 0, so the redirect occurs Link to comment https://forums.phpfreaks.com/topic/19832-case-sensitive-problem/#findComment-86795 Share on other sites More sharing options...
realjumper Posted September 6, 2006 Author Share Posted September 6, 2006 Whoops, I made a typo in printing above,the final solution shoiuld be[code]?php$a = 'a'; $b = 'A'; // my typo was here$compare = strcasecmp("$a","$b");if ($compare == '0'){ Header("Location: yipee_you_are_logged_in.php"); exit();}?>[/code] Link to comment https://forums.phpfreaks.com/topic/19832-case-sensitive-problem/#findComment-86798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.