title: How to replace a word in a file with a hyperlink in PHP?
body: <p>I need a help with replacing a word from a text file to a link using php</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;?php
  $search = 'google';
  $lines = file('f.txt');
  foreach($lines as $line)
  {
     if(strpos($line, $search) !== false)
     echo $search."\n";
     echo preg_replace('/google/', '&lt;a href="http://www.google.com/'&gt;&lt;/a&gt;',$lines);
  
     }
  }
  ?&gt;
  </code></pre>