3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Simplify { public static function Template($file, $variables) { $template = $file; preg_match_all("{{(\w*)}}", $template, $matches); foreach($matches[1] as $var) { if (array_key_exists($var, $variables)) { $output = str_replace('{{' . $var . '}}', $variables[$var], $template); } } echo $template; } } $template = "hfwlei ifaugweifg uwfgyakreu fvgw fwaeuif gonwiegf {{naam}} uywanfi awyuegfawuyegf {{email}}"; $vars = array("naam" => "Joran", "email" => "info@jorandesign.nl"); Simplify::Template($template, $vars);

preferences:
35.45 ms | 402 KiB | 5 Q