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? Quote Link to comment 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 Quote Link to comment 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 ... Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment 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.