array_count_values
Count the number of occurrences of all values in a one-dimensional array
<code><span>$array</span> = <span>array</span>(<span>1</span>, <span>"hello"</span>, <span>1</span>, <span>"world"</span>, <span>"hello"</span>); print_r(array_count_values(<span>$array</span>));</code>
Output:
<code><span>Array</span> ( [<span>1</span>] => <span>2</span> [hello] => <span>2</span> [world] => <span>1</span> )</code>
The above has introduced these useful techniques in PHP, including related content. I hope it will be helpful to friends who are interested in PHP tutorials.