I would like to count the occurrence of each duplicate item in an array and end up with an array of only unique/non duplicate items with their respective occurrences.
Answer (1)
Using following code you get result
$array = array(12,43,66,21,56,43,43,78,78,100,43,43,43,21);
$vals = array_count_values($array);
print_r($vals);
Result:
No. of NON Duplicate Items: 7
Array ( [12] => 1 [43] => 6 [66] => 1 [21] => 2 [56] => 1 [78] => 2 [100] => 1 );