Not really sure what you mean but maybe something like this?
This is template.html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Template</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</head>
<body>
<table>
<custom-tag>
</table>
</body>
</html>
And here is the PHP:
<?php
// load the content of the file:
$template = implode( "" , file( "template.html" ) );
// here is an array with some data:
$data = array( "Eric" , "Rick" , "John" , "Mary" );
// generate some data:
$saved_data = "";
for( $i = 0 ; $i < sizeof( $data ) ; $i++ )
{
// save it:
$saved_data .= "<tr>\n<td>Name: " . $data[$i] . "</td>\n</tr>" . ( ( $i == sizeof( $data ) - 1 ) ? "" : "\n" );
}
// replace it in the code:
$template = str_replace( "<custom-tag>" , $saved_data , $template );
// print the code:
echo $template;
?>