<?php
$template = "{{name}} говорит «{{phrase}}»";
$data = [
'name' => 'Иван',
'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+ICfQmNCy0LDQvScsCgkncGhyYXNlJyA9PiAn0L3QsNC00L4g0YPRhdC+0LTQuNGC0YwnCl07CgpmdW5jdGlvbiByZW5kZXIoJHRwbCwgJGRhdGEpIHsKCSRrZXlzID0gYXJyYXlfa2V5cygkZGF0YSk7Cglmb3IgKCRpID0gMDsgJGkgPCBjb3VudCgkZGF0YSk7ICRpKyspIHsKCQkkdHBsID0gcHJlZ19yZXBsYWNlKCcve3snLiRrZXlzWyRpXS4nfX0vJywgJGRhdGFbJGtleXNbJGldXSwgJHRwbCk7Cgl9CgkKCXJldHVybiAkdHBsOwp9CgplY2hvIHJlbmRlcigkdGVtcGxhdGUsICRkYXRhKTs=