Use strcmp
for that:
From the documentation:
Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
Code:
$str1 = 'foo';
$str2 = 'bar';
if(strcmp($str1, $str2) < 0) {
echo '$str1 comes first';
} elseif(strcmp($str1, $str2) > 0 ){
echo '$str2 comes first';
}
Output:
$str2 comes first