<?php
$template = '{greetings}, {user}! сталось времени: {time} мин., осталось попыток: {attempts}';
$data = array('time' => 10, 'attempts' => 4, 'user' => 'Петя', 'greetings' => 'Доброе утро');
function renderTemplate($template, $data) {
foreach ($data as $name => $value) {
$regexp = "/\{$name\}/";
}
return $template;
}
$result = renderTemplate($template, $data);
echo $result;
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKJHRlbXBsYXRlID0gJ3tncmVldGluZ3N9LCB7dXNlcn0hINGB0YLQsNC70L7RgdGMINCy0YDQtdC80LXQvdC4OiB7dGltZX0g0LzQuNC9Liwg0L7RgdGC0LDQu9C+0YHRjCDQv9C+0L/Ri9GC0L7Qujoge2F0dGVtcHRzfSc7CiRkYXRhID0gYXJyYXkoJ3RpbWUnID0+IDEwLCAnYXR0ZW1wdHMnID0+IDQsICd1c2VyJyA9PiAn0J/QtdGC0Y8nLCAnZ3JlZXRpbmdzJyA9PiAn0JTQvtCx0YDQvtC1INGD0YLRgNC+Jyk7CgpmdW5jdGlvbiByZW5kZXJUZW1wbGF0ZSgkdGVtcGxhdGUsICRkYXRhKSB7Cglmb3JlYWNoICgkZGF0YSBhcyAkbmFtZSA9PiAkdmFsdWUpIHsKCQkkcmVnZXhwID0gIi9ceyRuYW1lXH0vIjsKCQkkdGVtcGxhdGUgPSBwcmVnX3JlcGxhY2UoJHJlZ2V4cCwgJHZhbHVlLCAkdGVtcGxhdGUpOwoJfQoJcmV0dXJuICR0ZW1wbGF0ZTsKfQoKJHJlc3VsdCA9IHJlbmRlclRlbXBsYXRlKCR0ZW1wbGF0ZSwgJGRhdGEpOwplY2hvICRyZXN1bHQ7