title: how to delete a specific line from a file starting a string in php
body: <p>I have a text file names data.dat containing space separated strings on each line. I want to delete a whole line starting with a specific from it, Please provide tested php code for it. I'm using php 5.4+</p>
  
  <p>File Contents : </p>
  
  <pre><code>abc samle sample
  this abc sample
  xyz test sample sample
  </code></pre>
  
  <p>For example, I have <code>$str="this"</code>. So in this case I want to delete 2nd line, For general that could occur at first line or middle or end. Main thing is I dont want any empty line. So new file should be</p>
  
  <pre><code>abc samle sample
  xyz test sample sample
  </code></pre>