请帮助我,我需要合并多个数组,然后按数组值计数排序.以下是问题:
$array1 = array("abc","def","ghi","jkl","mno"); $array2 = array("mno","mno","pqr","stu"); $array3 = array_merge($array1,$array2); $array4 = ??? print_r($array4);
我想要$array4的返回值如下:
Array ( [0] => mno [1] => ghi [2] => jkl [3] => abc [4] => def [5] => pqr [6] => stu )
你可以做:
原文链接:https://www.f2er.com/php/130815.html$array1 = array("abc",$array2); // get the array of count. $array4 = array_count_values($array3); // sort it in reverse order. arsort($array4); // extract just the keys. $array4 = array_keys($array4);