您好需要帮助从给定数组中获取重复值,下面是我尝试获取最大值的代码$values[4]
$values = array(
"0"=> "abc",
"1"=> "aaa",
"2"=> "aaa|abc",
"3" => "| | | | | | | | | | | | | | | | ",
"4" => "a|b|b|c|d|e|f|g",
"5" => "1|2|3||4|5|6"
);
foreach ($values as $key) {
$prevalues = explode('|', $key);
$count[] = count($prevalues);
}
print_r($counts);
$counts = array_count_values($count);
arsort($counts);
echo $max= key($counts);
Array
(
[0] => 1
[1] => 1
[2] => 2
[3] => 17
[4] => 8
[5] => 8
)
print_r($max );
目前,我得到 $max = 1; 我需要 $max 为 8。