title: PHP find a keyword in text multiple times - display before/after charaters
body: <p>I am creating a search for a keyword in a string of text. For example: Let's say I want to find the word 'Happy' and how many times it shows up in a book. Then I want to display 100 characters before and after the word, and do this for every word 'Happy' it finds.</p>
  
  <p>I was able to find code to do it ONCE but how can I do this for all the occurrences of the keyword, in this case the word 'Happy'?</p>
  
  <p>Here is the working code that finds one occurrence and displays characters before and after.</p>
  
  <pre><code>$text= $Content;
  $find = 'Happy';
  $result = strpos($text, $find);
  echo substr($text,($result-100&gt;0)?($result-100):0,100)." ".$find." "
  .substr($text,$result+strlen($find),100); 
  </code></pre>
  
  <p><strong>How I can do this in a loop and find all the occurrences of a keyword?</strong> </p>