<?php
$template = "{{name}} говорит «{{phrase}}»";
$data = [
'name' => 'Иван {{phrase}}',
'phrase' => 'надо уходить'
];
function render($tpl, $data) {
for ($i = 0; $i < count($data); $i++) { $tpl = preg_replace('/{{'.$keys[$i].'}}/', $data[$keys[$i]], $tpl); }
return $tpl;
}
echo render($template, $data);
PD9waHAKCiR0ZW1wbGF0ZSA9ICJ7e25hbWV9fSDQs9C+0LLQvtGA0LjRgiDCq3t7cGhyYXNlfX3CuyI7CiRkYXRhID0gWwoJJ25hbWUnID0+ICfQmNCy0LDQvSB7e3BocmFzZX19JywKCSdwaHJhc2UnID0+ICfQvdCw0LTQviDRg9GF0L7QtNC40YLRjCcKXTsKCmZ1bmN0aW9uIHJlbmRlcigkdHBsLCAkZGF0YSkgewoJJGtleXMgPSBhcnJheV9rZXlzKCRkYXRhKTsKCWZvciAoJGkgPSAwOyAkaSA8IGNvdW50KCRkYXRhKTsgJGkrKykgewoJCSR0cGwgPSBwcmVnX3JlcGxhY2UoJy97eycuJGtleXNbJGldLid9fS8nLCAkZGF0YVska2V5c1skaV1dLCAkdHBsKTsKCX0KCQoJcmV0dXJuICR0cGw7Cn0KCmVjaG8gcmVuZGVyKCR0ZW1wbGF0ZSwgJGRhdGEpOw==