I would check on-the fly...
$dic=explode("\n",file_get_contents('dictionary.txt'));
$words=array();
$words=explode(" ",strtolower(file_get_contents('text.txt'));
foreach($words as $index=>$word) {
if(in_array($word,$dic)) {
// do something
} else {
// do something else
}
}
if the text is huge i would speed up the comparison by replacing in_array with isset like this...
$dic_temp=explode("\n",file_get_contents('dictionary.txt'));
$dic=array();
foreach($dic_temp as $k=>$v) {
$dic[$k]=1;
}
unset($dic_temp);
$words=array();
$words=explode(" ",strtolower(file_get_contents('text.txt'));
foreach($words as $index=>$word) {
if(isset($dic[$word])) {
// do something
} else {
// do something else
}
}