str::template($string, $data = array())

A super simple string template engine, which replaces tags like {mytag} with any other string

  • $string (string)
  • $replace (array)
    An associative array with keys, which should be replaced and values.
  • return (string)


$string = '{key1} is a {key2} {key3}';
$data = array(
  'key1' => 'Kirby'
  'key2' => 'file-based',
  'key3' => 'CMS',
$result = str::template($string, $data);

echo $result;


Kirby is a file-based CMS

Is something missing or incorrect? Edit this page on Github…