onedumbcoder Posted May 23, 2008 Share Posted May 23, 2008 is there a way to test if a letter is larger then another one? for example B is "larger" then A. Quote Link to comment https://forums.phpfreaks.com/topic/106975-solved-comparing-letters/ Share on other sites More sharing options...
GingerRobot Posted May 23, 2008 Share Posted May 23, 2008 As long as you keep the letters the same case, then you shouldn't have any troubles with a simple if statement: <?php $one = 'b'; $two = 'a'; if($one > $two){ echo $one.' is bigger than '.$two; }else{ echo $one.' is NOT bigger than '.$two; } ?> I suspect PHP handles this by converting to an ASCII value or similar, hence why you may not get the requried results if the letters are of different cases. Quote Link to comment https://forums.phpfreaks.com/topic/106975-solved-comparing-letters/#findComment-548334 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.