In my own function, First i want to include one html file, Then if in that included file, we find another html file name, i want to merge content of first included file and second included file.
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<$len){
$file = preg_replace("/$include_pattern/s","$2",$match[0][$i]);
ob_start();
include($file);
$output = ob_get_contents();
ob_end_clean();
//$output = $this->inc($output);
$html = str_replace($match[0][$i],$output,$html);
$i++;
}
return $html;
}
}
In this function, if you look at the commented part in the code, i was tried for get content of 2nd included html file. Imagine, if we include 1.html, if in this included file we have 2.html, how we can show content of 2.html and content of 1.html ?
If you look at image in below, its clear for understand current topic. ( i want to get result like “result box” in the image).

I fix issue in my function. There is changed function and work well…