title: Remove entire <li> element if content match
body: <p>I have scraped html in a string and only wish to display certain list elements. For example, if the list element contains the word 'Banana' then remove entire line from html.</p>
  
  <p>For example in the following block, how would I use preg_replace or similar to remove the enitire <li> element?</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li class="x"&gt;Apple - Green&lt;/li&gt;
    &lt;li class="x"&gt;&lt;span&gt;Orange&lt;/span&gt; - Orange&lt;/li&gt;
    &lt;li id="active" class="x"&gt;Banana - Yellow&lt;/li&gt;
    &lt;li class="z"&gt;&lt;span&gt;Grapefruit&lt;/span&gt; - Yellow&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>And end up with </p>
  
  <pre><code>&lt;ul&gt;
    &lt;li class="x"&gt;Apple - Green&lt;/li&gt;
    &lt;li class="x"&gt;&lt;span&gt;Orange&lt;/span&gt; - Orange&lt;/li&gt;
    &lt;li class="z"&gt;&lt;span&gt;Grapefruit&lt;/span&gt; - Yellow&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Bearing in mind the class and span tags are dynamic and may or may not appear.</p>
  
  <p>I thought of using preg_replace but my skills are limted to only replacing the word 'Banana' but leaving 'Yellow'. I want to remove that entire line.</p>