My data source is in utf8 format, but I want to sort the data. because it is Chinese, I convert it to gbk or gbk2312, however, the sorting is partially inaccurate. I am using the array_multi_sort method of php to sort the results. in the black box, the data is very...
My data source is in utf8 format, but I want to sort the data. because it is Chinese, I want to convert it to gbk or gbk2312, but the sorting is partially inaccurate.
I used the php array_multi_sort method for sorting.
This problem occurs in Sorting results.
The data in the black box is obviously incorrectly arranged in descending order of pinyin, but the subsequent data is suitable. why? Or is the gbk Library incomplete?
Add a test code
$ Array = array ("Heron", "hao", "Han", "Hua", "Zhong", "Yi", "Cui", "Zhong ", "Kai", "Xin"); foreach ($ array as $ val) {$ newArr [] = iconv ('utf8', 'gbk', $ val );} array_multisort ($ newArr, SORT_DESC, SORT_FLAG_CASE); echo"";print_r($newArr);die;
Reply content:My data source is in utf8 format, but I want to sort the data. because it is Chinese, I want to convert it to gbk or gbk2312, but the sorting is partially inaccurate.
I used the php array_multi_sort method for sorting.
This problem occurs in Sorting results.
The data in the black box is obviously incorrectly arranged in descending order of pinyin, but the subsequent data is suitable. why? Or is the gbk Library incomplete?
Add a test code
$ Array = array ("Heron", "hao", "Han", "Hua", "Zhong", "Yi", "Cui", "Zhong ", "Kai", "Xin"); foreach ($ array as $ val) {$ newArr [] = iconv ('utf8', 'gbk', $ val );} array_multisort ($ newArr, SORT_DESC, SORT_FLAG_CASE); echo"";print_r($newArr);die;
If the sorting results by Chinese characters are not necessarily accurateasciiSorting, but the complexity of the program increases. if your classified data is read from the database, try to add it to the database.Sorting field