title: PHP How to show search results like search engine
body: <p>I have a search page in my website.<br>
  I don't want to show the entire sentence in the results, I would like to show it in "Google style":<br>
  5 characters before, <strong>searched word highlighted</strong>, 5 characters after...<br>
  and so on, for every word found in the sentence.</p>
  
  <pre><code>$teksto="bla1 bla2 bla3 bla4 bla5 Bingo bla6 bla7 bla8 bla9 bla10 Bingo bla11 bla12 Bingo bla13 bla14 bla15";
  $serchu="bingo";
  $teksto=preg_replace("/[\s]{1,}/is",' ',$teksto); // (form multispaces, breaklines, etc. to just 1 space)
  echo preg_replace("/(.{0,5})($serchu)(.{0,5})/is"," ...$1&lt;b&gt;$2&lt;/b&gt;$3... &amp;nbsp;&amp;nbsp;",$texto);
  </code></pre>
  
  <p>The result is:<br>
  bla1 bla2 bla3 bla4 ...bla5 <b>Bingo</b> bla6...    <strong><em>bla7 bla8 bla9 b</em></strong> ...la10 <b>Bingo</b> bla1...   <strong><em>1 b</em></strong> ...la12 <b>Bingo</b> bla1...   3 bla14 bla15</p>
  
  <p>I would like the result could be:<br>
  ...bla5 <b>Bingo</b> bla6...   ...la10 <b>Bingo</b> bla1...   ...la12 <b>Bingo</b> bla1...</p>
  
  <p>In other words, i don't want <strong><em>the other words</em></strong>, at the beginning or end.<br>
  MySQL solution also appreciated.</p>