What are some common pitfalls when using count() and array_count_values() in PHP for counting elements in an array?

One common pitfall when using count() and array_count_values() in PHP for counting elements in an array is that count() only returns the number of elements in the array, not the count of unique values. Similarly, array_count_values() only counts the occurrences of each unique value in the array, not the total number of elements. To get the count of unique values in an array, you can use array_unique() in combination with count().

// Sample array
$array = [1, 2, 2, 3, 3, 3];

// Count unique values in the array
$uniqueCount = count(array_unique($array));

echo $uniqueCount; // Output: 3