title: RegExp replace a specific XML/HTML TAG in PHP
body: <p>I have a little script that replace some text, that come from a xml file, this is an example:</p>
  
  <pre><code>&lt;b&gt;Hello world,&lt;/b&gt;
  &lt;include file="dynamiccontent.php" /&gt;
  &lt;img src="world.png" /&gt;
  a lot of &lt;i&gt;stuff&lt;/i&gt;
  </code></pre>
  
  <p>Obviosly the string is much more longer, but I would like to replace the <code>&lt;include
   file="*" /&gt;</code> with the content of the script in the filename, at time I use an explode that find</p>
  
  <pre><code>&lt;include file="
  </code></pre>
  
  <p>but I think there is a better method to solve it.
  This is my code:</p>
  
  <pre><code>$arrContent = explode("&lt;include ", $this-&gt;objContent-&gt;content);
      foreach ($contenuto as $piece) { // Parsing array to find the include
          $startPosInclude = stripos($piece, "file=\""); // Taking position of string file="
          if ($startPosInclude !== false) { // There is one
              $endPosInclude = stripos($piece, "\"", 6);
              $file = substr($piece, $startPosInclude+6, $endPosInclude-6);
              $include_file = $file;
              require ($include_file); // including file
              $piece = substr($piece, $endPosInclude+6);
          }
          echo $piece;
      }
  </code></pre>
  
  <p>I'm sure that a regexp done well can be a good replacement.</p>