How to compare 2 strings alphabetically in PHP?

前端 未结 5 975
青春惊慌失措
青春惊慌失措 2021-02-04 23:34

What the title says. Specifically if I have

$array1[\'name\'] = \'zoo\';
$array2[\'name\'] = \'fox\';

How can I determine that alphabetically <

5条回答
  •  我在风中等你
    2021-02-04 23:47

    You can compare both strings with strcmp:

    Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

提交回复
热议问题