こんにちは、指定された配列から繰り返し値を取得するのに助けが必要です。以下は、最大値を取得しようとしているコードです$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 にする必要があります。