How to compare 2 strings alphabetically in PHP?

前端 未结 5 973
青春惊慌失措
青春惊慌失措 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:55

    I often use natsort (Natural Sort), since I usually just want to preserve the array for later use anyway.

    Example:

    natsort($unsorted_array);
    
    var_dump($usorted_array); // will now be sorted.
    

提交回复
热议问题