PHP will compare alpha strings using the greater than and less than comparison operators based upon alphabetical order.
-
In the first example,
ai
comes beforei
in alphabetical order so the test of>
(greater than) isfalse
– earlier in the order is considered ‘less than’ rather than ‘greater than’. -
In the second example,
ia
comes afteri
alphabetical order so the test of>
(greater than) istrue
– later in the order being considered ‘greater than’.