I wonder if anyone can help with a little problem I can\'t seem to fix - my head is going round in circles at the moment...
Ok I have a .txt file with numerous lines of
Here's my code:
$searchTerms = explode(' ', $search);
$searchCount = count($searchTerms);
foreach($lines as $line)
{
if ($counter <= 4) {
$matchCount = 0;
foreach ($searchTerms as $searchWord) {
if (strpos($line, $searchWord) !== false ) {
$matchCount +=1;
} else {
//break out of foreach as no need to check the rest of the words if one wasn't found
continue;
}
}
if ($matchCount == $searchCount) {
$found = true;
$line = ' '.$line.'
';
echo $line;
$counter = $counter + 1;
}
}
}