Hi Gurus,
I am attempting to write a function that will go through a block of text and extract the needle and from the haystack. But I want the text before and after the needle as well.
I am attempting to write a function that will go through a block of text and extract the needle and from the haystack. But I want the text before and after the needle as well.
Code:
function findTerms($term, $content)
{
strip_tags($content);
$pieces = explode(".", $content);
preg_match_all("/\b$term\b/i", "$pieces",$out);
print_r($out);
}
findTerms("sporting goods", "The year was 1800 and sporting goods were not even thought of. We all looked out and saw sporting goods. And then he said, I like peanut butter.");