title: Highlight keywords in a paragraph
body: <p>I need to highlight a keyword in a paragraph, as google does in its search results. Let's assume that I have a MySQL db with blog posts. When a user searches for a certain keyword I wish to return the posts which contain those keywords, but to show only parts of the posts (the paragraph which contain the searched keyword) and to highlight those keywords. </p>
  
  <p>My plan is this:  </p>
  
  <ul>
  <li>find the post id which has the searched keyword in it's content;</li>
  <li>read the content of that post again and put each word in a fixed buffer array (50 words) until I find the keyword.</li>
  </ul>
  
  <p>Can you help me with some logic, or at least to tell my if my logic is ok? I'm in a PHP learning stage. </p>