$arrvalue=['A','B','C','A','C','D','A','B'];
$findArr = ['A', 'B', 'C', 'D'];
$arrCount = [];
foreach ($findArr as $value) {
$arr = array_filter($arrValue, function ($val) {
return $val == $value;
});
array_push($arrCount, count($arr));
}
I want to count how many times each of A, B, C, and D appear in the $arrValue
array and put it in the $arrCount
array. For example, something like this. [3,2,2,1]. However, the $value value is not recognized in the array_filter function. What's the problem?