Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 排序数组有错误,没有英文键_Php_Arrays_Sorting - Fatal编程技术网

Php 排序数组有错误,没有英文键

Php 排序数组有错误,没有英文键,php,arrays,sorting,Php,Arrays,Sorting,我有一个这样的数组 我必须按价值排序 数组键是非英语的 33必须在第一个和24,10和7等 但是当我使用sort、asort或uksort时,它只返回1 1 使用非英语语言作为键的这些函数和数组是否有任何问题 代码: 好的,让我们看看: $nextArray = array_count_values($arr1); // this is an array $nextArray = sort($nextArray); // as *sort function retu

我有一个这样的数组 我必须按价值排序

数组键是非英语的

33必须在第一个和24,10和7等 但是当我使用sort、asort或uksort时,它只返回1

1 
使用非英语语言作为键的这些函数和数组是否有任何问题

代码:

好的,让我们看看:

$nextArray = array_count_values($arr1);   // this is an array
$nextArray = sort($nextArray);            // as *sort function return bool you overwrite array value with bool value

print_r($nextArray);
正确的代码应为:

$nextArray = array_count_values($arr1);
sort($nextArray);
print_r($nextArray);

*排序函数返回布尔值,而不是数组。你知道吗?不知道!但是打印后不要返回任何东西!您可以阅读php中的排序;然后,您可能需要获得预期的排序,您使用什么样的代码来排序和打印?
$nextArray = array_count_values($arr1);   // this is an array
$nextArray = sort($nextArray);            // as *sort function return bool you overwrite array value with bool value

print_r($nextArray);
$nextArray = array_count_values($arr1);
sort($nextArray);
print_r($nextArray);