Here私のコードです:array_count_values()の結果をどのようにソートできますか?
<?php
$array = array("world", 1, "hello", 1, "hello", "hello", "how");
$new_array = array_count_values($array);
print_r($new_array);
?>
/* Output:
Array
(
[world] => 1
[1] => 2
[hello] => 3
[how] => 1
)
今、私は新しい配列の値に基づいて結果をソートします。これは期待される出力です:
/* Expected Output:
Array
(
[hello] => 3
[1] => 2
[world] => 1
[how] => 1
)
どうすればいいですか?
注:同じ値の順序は関係ありません。
アソートを試すhttp://php.net/manual/en/function.asort.php OR arsort http://php.net/manual/en/function.arsort.php – Ima
arsort()を使って配列をソートするその値によって – JYoThI