<?php function foo() { return "Wykopek"; } function bar($a) { return $a . ' harnasia'; } $template = "Michał {{foo}} kończył {{bar, 5}}."; $result = preg_replace_callback('/{{([^}]+)}}/', function($matches) { $parts = explode(', ', $matches[1]); $functionName = array_shift($parts); return $functionName(...$parts); }, $template); echo $result;
You have javascript disabled. You will not be able to edit any code.