I have a body of text returned from a search query, lets call it $body. Now, what I want to do is for the script to find the first occurrence of the search query, $query. I know I can find this first occurrence this with strripos.
Once found, I want the script to return a couple of words before the first occurrence of the string as well as a few words after the end of the first occurrence.
Essentially I'm trying to do what Google does with it's search results.
Any ideas on where I should start? My issue is that I keep returning partial words.