Dynamically counting frequency of element in a array in PHP
<p>I have an array say:</p>

<pre><code>$array = array(1, 5, 2, 3, 3, 4, 5, 1)
</code></pre>

<p>I want to convert this array and having the value as the key and its frequency as the value
output should be like:</p>

<pre><code>$array = array (
         "1" =&gt; 2,
         "2" =&gt; 1,
         "3" =&gt; 2,
         "4" =&gt; 1,
         "5" =&gt; 2
)
</code></pre>

<p>I know how to do this in python. But I have to do it in PHP. I have implemented this in python with follwoing code:
python code:</p>

<pre><code>d = {}
for j in tweets: // tweet is a array of integers as given above $array
d[j] = d.get(j, 0) + 1 // This will make a dictionary with the values in the array as key and its frequency as value of the dictionary .. Get() dynamically increase the value
</code></pre>

<p>Please help.</p>
