3v4l.org

run code in 500+ PHP versions simultaneously
<?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;

preferences:
53.86 ms | 1417 KiB | 5 Q