This function:
function parse_template($filename) {
$template_contents = "";
//open the template file or die.
if(!file_exists($filename)) {die("Template ($filename) does note exist.");}
if(!$fp = fopen($filename,'r')) {die("Could not open template ($filename).");}
$lines = file($filename);
//here is the problem, explained below code
$globals = split(",",array_shift($lines));
foreach ($globals as $gbl) {global $$gbl;}
$template_contents = implode("",$lines);
//abra-ka-regex
$template_contents = preg_replace("/\[(\w+)\]/e","\$\$1",$template_contents);
return $template_contents;
} //end parse_template
Here is the problem if I have a template that looks like this:
one,two,three
<b>[one]</b> - <b>[two]</b> - <b>[three]</b>
then three has no value. But if I change the template to this:
one,two,three,junk
<b>[one]</b> - <b>[two]</b> - <b>[three]</b>
three has the expected value.
What am I going wrong here?