you could use:
$indata = explode(" ",implode(file("text.txt")));
Now you should have an array with all the letter groupings in it. you can step through the array one key at a time and create a new asoc array with the word as a key. e.g
for($cnt=0;$cnt <= count($indata)-1;$cnt++){
$words["$indata[$cnt]"]++;
}
if you want to find the word PHP, simply display..
$words["PHP"]
and it will tell you how many times that word was in the document.
That is one way to do it.