title: preg_match exact word and print out the entire line the result was found in
body: <p>i'm having a hard time understanding how to do this.</p>
  
  <p>I want to search for a word, and then I want the search to return the word along with all the contents on the line the word was found in.</p>
  
  <p>The word needs to be case sensitive so searching for TOM will not return Tom along with the results.</p>
  
  <p>this is what I have tried thus far.</p>
  
  <pre><code>$contents = file_get_contents($file);
  $pattern = preg_quote($word, '/');
  $numInt  = 0;
  $pattern = "/^.*$pattern.*\$/m";
  if(preg_match_all($pattern, $contents, $matches))
  {
      $numInt = count($matches[0]);
  }
  </code></pre>
  
  <p>When I run this through my function it returns the results I want, but I noticed that it isn't consistant across different keyword.</p>
  
  <p>In my text file for testing I have <code>INT (x18)</code> and my function returns 18 as the count. But if I use the keyword <code>MORNING (x29)</code> the function returns 31 which is technically correct because there are 2 instances where <code>morning</code> is used. </p>