Forum Moderators: coopster
print preg_replace_callback("/\€([^\{]{1,100}?)\€/",
function ($matches){return $GLOBALS[$matches[1]];}, file_get_contents("template.tpl"));
<html>
<head>
<title>€title€</title>
</head>
<body>
<h1>€header€</h1>
€text€
</body>
</html> $title="Example page";
$header="My Examples";
$text="See the placeholders replaced?";
$var=array(
"€title€"=>"Example page",
"€header€"=>"My Examples",
"€text€"=>"See the placeholders replaced?"
);
echo str_replace(array_keys($var),array_values($var),file_get_contents("template.tpl"));