/', $template[$i]) ) { // ok, we found a begin block... let's skip it for now. while($tmp = preg_match('//', $template[$i])) { if ($tmp == TRUE) { // we succeeded in finding the end, stop. break; } if($i = count($template) ) { // oops, no end block, let's break out of this. break; } $i++; } } $keys = array_keys($vars); for($j=0; $j/', $template[$i]) ) { // ok, found the block we're looking for... let's find and replace the variables $begin = $i+1; } if( preg_match('//', $template[$i]) ) { // we're at the end, break. $end = $i-1; } } for($i=$begin; $i<($end+1); $i++) { for($j=0; $j and // Not useful, not terrible, I say trash it. // $template[$begin-1] = ''; $template[$end+1] = ''; return $template; } /******************************************************************************* * function: show_template() * * parameters: template [string] * * returns: nothing. * * extra: be sure you've sent all headers before calling this. * * also, this will not assemble multiple templates you have parsed. * * do that individually. * *******************************************************************************/ function show_template($template) { // ok, all our work has done, let's just spit it out. for($i=0; $i < count($template); $i++) { echo $template[$i]; } }