Issue in my function for include files with template tag
<p>In my own function, First i want to <code>include</code> one <code>html</code> file, Then if in that included file, we find another <code>html</code> file name, i want to merge content of first included file and second included file.</p>

<pre><code>function inc($html){
$include_pattern = "\{\s*include\s*(\(|')\s*([a-zA-Z0-9-.\/-_]+)\s*(\)|')\s*\}";
preg_match_all("/$include_pattern/s",$html,$match);
if($len = count($match[0])){
$i=0;
        while($i&lt;$len){
$file = preg_replace("/$include_pattern/s","$2",$match[0][$i]);

ob_start(); 
         include($file);
         $output = ob_get_contents();
         ob_end_clean();
//$output = $this-&gt;inc($output);
        $html = str_replace($match[0][$i],$output,$html);

$i++; 
     }
return $html;

       }
}
</code></pre>

<p>In this function, if you look at the commented part in the code, i was tried for get content of 2nd included <code>html</code> file. Imagine, if we include <code>1.html</code>, if in this included file we have <code>2.html</code>, how we can show content of <code>2.html</code> and content of <code>1.html</code> ?</p>

<p>If you look at image in below, its clear for understand current topic. ( i want to get result like "result box" in the image).</p>

<p><img src="http://i.stack.imgur.com/KFTAi.png" alt="enter image description here"></p>
