I've been working too hard today and I can't figure out how to change the value inside the <!-- title --> to $title automatically.

I've tried

$template = eregi_replace("<!-- ".$value." -->", $value, $template)

but that's not doing anything. Here's what I'm using now
PHP Code:
$title "hello";
$bodytext "test";

$filename "theme.html";
$fp fopen($filename,"r");
$template .= fread($fp,filesize($filename));
$template eregi_replace("<!-- title -->",$title,$template);
$template eregi_replace("<!-- bodytext -->",$bodytext,$template);

I just want to cut out doing the

$template = eregi_replace("<!-- bodytext -->",$bodytext,$template);

for every single tag in the template.