Hi everyone below is my PHP code. I have basically made an algorithm so when a name is inputted in the $string section, that name is searched and depending on the first letter in the name it will be placed within a group, either group 1 or 2.
I run into a problem as whenever i search for a name beginning with P it outputs group 2 when it should be group 1. any idea why this is? i need it to output group 1 with names a-p and group 2 for names after p.
$string = "Peter"; //Input surname here!
$firstCharacter = substr($string, 0, 1); //Finds the first letter in the String
$firstCharacter = strtoupper($string); //Converts string into uppercase
echo ($string > 'P') ? 'Group1' : 'Group2';