I am looking for a way to extract X number of words on either side of a given word in a search.
For example, if a user enters "inmate" as a search word and the MySQL query finds a post that contains "inmate" in the content of the post, I would like to return not the entire contents of the post but just x number of words on either side of it to give the user the gist of the post and then they can decide if they want to continue on to the post and read it in full.
I am using PHP.
Thanks!
See Question&Answers more detail:os