私は 2 つの配列 (これはより多くの配列である可能性があります) を持っており、最も多く表示される値を見つける必要があります。
array(2) {
[0]=>
string(6) "PD0001"
[1]=>
string(6) "PD0002"
}
array(2) {
[0]=>
string(6) "PD0001"
[1]=>
string(6) "PD0003"
}
だから私はPD0001を見つけようとしています、何か提案はありますか?
これを実行できるスクリプトを次に示します。
// First merge the arrays together
$array = array_merge($array1, $array2);
// Get the array counts like this:
$counts = array_count_values($array);
// Sort the array so the first one has the highest count
arsort($counts);
// Get the first key:
reset($counts);
$maxElement = key($counts);