Interview - how calculate the frequency of each word in a text file
<p>I had an interview where I could use any language I wanted to in order to calculate how many times each word appeared in a text file. </p>

<p>I solved it in C by reading in each word and adding it to a tree structure - If the word was all ready in the structure, the algorithm would add one to a counter I added in the node.</p>

<p>Well the person said I had to much code and it was messy, and said I could do it in PHP with about 3 lines of code.</p>

<p>I started to use the <code>explode()</code> to separate the string into a array of words, but was stuck after that.</p>

<p>Does anybody know how this could be done in PHP with a couple lines of code?</p>
