Write a function named count_duplicates
that accepts an array of integers as a parameter and that returns the
number of duplicate values in the array. A duplicate value is a value that also occurs earlier in the array.
For example, if an array named $arr
contains [1, 4, 2, 4, 7, 1, 1, 9, 2, 3, 4, 1]
, then the call
of count_duplicates($arr)
should return 6
because there are three duplicates of the value 1,
one duplicate of the value 2, and two duplicates of the value 4.
If the array passed is empty or contains only one element, your function should return 0.