title: Match words in file with regex php
body: <p>I'm new with regex and php. I know this quite simple but i just can't get it. Now, i have file words.txt that contain:</p>
  
  <pre><code>happy
  sad
  laugh
  </code></pre>
  
  <p>I want to find match this sentence with my words.txt:</p>
  
  <blockquote>
    <p>I am happy</p>
  </blockquote>
  
  <p>So far, i've tried this but it doesn't valid because it read as a sentence not words: (not yet implement regex bcs im confused)</p>
  
  <pre><code>$input0= "I am happy";
  $handle = fopen('words.txt', 'r');
  $valid = false; 
  while (($buffer = fgets($handle)) !== false) {
  if (strpos($buffer, $input0) !== false) { // here's the problem
      $valid = TRUE;
      break;
     }      
  }
  if($valid == TRUE){
  //print the matches word
  }
  fclose($handle);
  </code></pre>
  
  <p>can u help me? :(</p>