title: How can I modify my PHP code using DomDocument, to remove the parentheses and the words they contain?
body: <p>I am trying to remove with <code>DomDocument</code> and the <code>str_ireplace</code> function, all the <code>span</code> tags having the <code>class</code> attribute containing <code>language-indicator</code> which are often words in parentheses including: <code>(d)</code>, <code>(en)</code>.</p>
  <p><strong>It works</strong> BUT <em>the problem is that it only removes the words that are in the parenthesis: <code>d</code>, <code>en</code>. AND does not remove the parentheses themselves at all: <code>()</code>.</em></p>
  <pre><code>    libxml_use_internal_errors(true);
      $parser = new DOMDocument();
      $parser-&gt;loadHTMLFile(&quot;https://fr.wikipedia.org/wiki/Mark_Zuckerberg&quot;);
      $get_span_tags = $parser-&gt;getElementsByTagName(&quot;span&quot;);
      foreach ($get_span_tags as $get_span_tag) {
              if (stripos($get_span_tag-&gt;getAttribute('class'), &quot;indicateur-langue&quot;) !== false) {
                  $get_infoxbox_span = $parser-&gt;saveHTML($get_span_tag);
                  $wikipediaInfoboxTable = str_ireplace($get_infoxbox_span, &quot;&quot;, $wikipediaInfoboxTable);
              }
          }
          
  echo $wikipediaInfoboxTable;
  </code></pre>
  <p>So <strong>how can I modify my code to also remove the parentheses and the words they contain because currently the words are removed and the parentheses <code>()</code> are not ???</strong></p>
  <p>Thank you for helping me.</p>