creating an array whose key and value is defined
<p>This code below basically will count the number of occurrences of a word inside an array.</p>

<p>What I would like to happen now though, is to get <code>$word</code>, assign it as a key to an array, and assign <code>$WordCount[$word]</code> to be its value. So for example, if I get, a word "jump", it will be automatically assigned as the key of an array, and  the number of occurrences of the word "jump" (<code>$WordCount[$word]</code>) will be assigned as its value. Any suggestions please?</p>

<pre><code>function Count($text)
{
    $text = strtoupper($text);
    $WordCount = str_word_count($text, 2);

    foreach($WordCount as $word)
    {   
        $WordCount[$word] = isset($WordCount[$word]) ? $WordCount[$word] + 1 : 1;
        echo "{$word} has occured {$WordCount[$word]} time(s) in the text &lt;br/&gt;";                       
    }
}
</code></pre>
