hello, everyone:
I have met a problem, when I read some template files, I need replace some variable in it.
e.g.
-----test.tpl-----
<html>
<head><title>$myvar[1001]</title></head>
<body>
$myvar[1002]
$myvar[2042]
$myvar[3004]
</body>
</html>
you know, all the variables in the template is an array. but not every template file have so many variables, maybe none, maybe several, maybe dozens, so I need replace these variable. I use a function such as:
function loadTemplateFile($file = "") {
global $myvar;
$fp = fopen($file,"r");
$output = fread($fp,filesize($file));
fclose($fp);
//I need replace the variable here, maybe need eregi_replace or preg_replace, but I am not familiar with them.
return $output;
}
expect you can help me, thank you!
LNFreish