Basically I’m trying to parse my template with preg_replace by finding anything that looks like {$variable} on the HTML file.
public function parse_file($file) {
return preg_replace('/{\$(.+?)}/i', "$this->params[$1]", $this->get_file($file));
}
However, this is returning Array(variable), instead of whatever variable is set to in the $this->params array.
I’d like it to return $this->params['variable'].
To clarify, this is what my HTML file looks like.
<!DOCTYPE html>
<html>
<head>
<title>{$variable}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>TODO write content</div>
</body>
</html>
Try
preg_replace_callback()instead, eg (PHP 5.3)