noxiousonline
New Member
I know I shouldn't be "reinventing the wheel" - (read other questions), but this is merely for practice. Here's my code:Template.php\[code\]$template = file_get_contents($path);foreach ($this->vars as $key => $value) { $template = preg_replace('/<!-- BEGIN ' . $key . ' AS (.*) -->/', '<?php foreach (' . $value . ' as $1) : ?>', $template); $template = preg_replace('/<!-- END ' . $key . ' -->/', '<?php endforeach; ?>', $template);}eval(' ?>' . $template . '<?php ');\[/code\]index.html\[code\]<!-- BEGIN names AS name --> test<!-- END names -->\[/code\]The $this->vars array\[code\]Array( [names] => Array ( [t] => test [j] => john [m] => max ) [page_title] => Home)\[/code\]But when I execute this code, I get:\[quote\] Notice: Array to string conversion
Parse error: syntax error, unexpected 'as' (T_AS), expecting '('\[/quote\]
Parse error: syntax error, unexpected 'as' (T_AS), expecting '('\[/quote\]