I have an array like this:
$arr = [
1 => ['A' => '1', 'C' => 'TEMU3076746'],
2 => ['A' => '2', 'C' => 'FCIU5412720'],
3 => ['A' => '3', 'C' => 'TEMU3076746'],
4 => ['A' => '4', 'C' => 'TEMU3076746'],
5 => ['A' => '5', 'C' => 'FCIU5412720']
];
My goal is to count the distinct values in the C
column of the 2-dimensional array.
The total rows in the array is found like this: count($arr)
(which is 5
).
How can I count the number of rows which contain a unique value in the 'C' column?
If I removed the duplicate values in the C
column, there would only be: TEMU3076746
and FCIU5412720
My desired output is therefore 2
.