I have a large array. I don’t need to bring my own method. How to do it?
I have a large array. I don’t need to bring my own method. How to do it?
Why not use PHP’s built-in function array_count_values
No need to bring your own methods
<code> $tagList = array("Cat", "Dog", "Horse", "Dog"); $count = array(); foreach ($tagList as $tVal) { if (!isset($count[$tVal])) { $count[$tVal] = 1; } else { $count[$tVal]++; } }</code>