How to Replacing delimiter with PHP variables


if (preg_match_all("/{{(.*?)}}/", $template, $m)) {
  foreach ($m[1] as $i => $varname) {
    $template = str_replace($m[0][$i], sprintf('$%s', $varname), $template);
  }
}