function process_template ( $content, $template )
{
$file = fopen ( $_SERVER['DOCUMENT_ROOT'] . '/template.html', 'r');
$contents = fread ( $file, filesize ( $_SERVER['DOCUMENT_ROOT'] . '/template.html' ) );
foreach ( $content as $key => $value )
{
$output = str_replace ( $value, $key, $contents );
}
fclose ( $file );
//print_r ( $content );
echo $output;
}
$content = array ( 'example.com' => '{site_name}',
'untitled document' => '{site_title}'
);
process_template ( $content, 'template.html');
At the moment it only replaces the first instance in the template.html being 'site_title'. How would I make it replace all instances of other strings I may add to the array?