Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要对包含来自不同语言的字符串的数组进行排序。我发现的最好方法如下:
setlocale(LC_COLLATE, 'tr_TR.utf8'); // or any other locale I use. uasort($aInput['values'],'strcoll');
即使 uasort 完美运行,它也存在整数问题并显示警告:
strcoll() 期望参数 1 是字符串
我应该在调用 uasort 之前循环整个数组并将整数值转换为字符串还是有其他方法?
您可以尝试使用区域设置对其进行多维排序。
array_multisort($aInput['values'], SORT_LOCALE_STRING);