For example, for sorting provinces, "chongqing" was originally regarded as "chongqing", but the sorting in php was identified as "zhongqing", so the sorting result is incorrect. Is there a simple solution to this problem? For example, for sorting provinces, "chongqing" was originally regarded as "chongqing", but the sorting in php was identified as "zhongqing", so the sorting result is incorrect.
Is there a simple solution to this problem?
Reply content:
For example, for sorting provinces, "chongqing" was originally regarded as "chongqing", but the sorting in php was identified as "zhongqing", so the sorting result is incorrect.
Is there a simple solution to this problem?
Function sortFunction ($ str1, $ str2) {return strcmp ($ str1 [1], $ str2 [1]);} $ arr = array ("Chongqing ", "chongqing"), array ("beijing", "beijing"), array ("tianjin", "tianjin"), array ("dalian", "dalian "),); usort ($ arr, "sortFunction"); // $ sortedArr is the sorted array $ sortedArr = array (); foreach ($ arr as $ item) {$ sortedArr [] = $ item [0];}