title: Search string and return line containing the string
body: <p>I have to create website using php that can search a word and return a line containing the word from 3 input text that been fixed. I've able to search a word and check whether it exist inside the input text. How can i search and return the output a line containing the word</p>
  
  <p>here are some data from the input file</p>
  
  <pre><code>&lt;paragraph&gt;&lt;Date&gt;&lt;Date&gt;TUESDAY&lt;/Date&gt;&lt;/Date&gt;. &lt;Date&gt;MARCH 3, 1903&lt;/Date&gt;
  Outstation Prosperity.
  &lt;/paragraph&gt;
  &lt;paragraph&gt;THE perusal of the various Annual Reports from Outstations is interesting: and very minutely shows the work of the Country.
  &lt;/paragraph&gt;
  </code></pre>
  
  <p>here are my coding that i have done</p>
  
  <pre><code>&lt;?php
  $path = 'D:\Collective Intelligence\assignment&amp;project\PROJECT-DATASET';
  $findThisString = $_POST['search1'];
  
  $dir = dir($path);
  
  // Get next file/dir name in directory
  while (false !== ($file = $dir-&gt;read()))
  {   
      if ($file != '.' &amp;&amp; $file != '..')
      {
          // Is this entry a file or directory?
          if (is_file($path . '/' . $file))
          {
              // Its a file, yay! Lets get the file's contents
              $data = file_get_contents($path . '/' . $file);
  
              // Is the str in the data (case-insensitive search)
              if (stripos($data, $findThisString) !== false)
              {
                  // sw00t! we have a match
              echo 'match found in ' . $file . "&lt;br&gt;\n";
  
              }
          }
      }
  }
  
  $dir-&gt;close();
  
  ?&gt;
  </code></pre>