array_count_values
計算一維數組中所有值出現的個數
<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>
輸出:
<code><span>Array</span> ( [<span>1</span>] => <span>2</span> [hello] => <span>2</span> [world] => <span>1</span> )</code>
以上就介紹了PHP裡面還有這些好用的技巧,包括了方面的內容,希望對PHP教程有興趣的朋友有幫助。