$_buf = array(
"SERVICE" => "/page/uslugi",
"CONTACT" => "/contact",
"EMAIL" => "email@domain.zone",
"TG.CANNEL" => "https://t.me/cannel",
"TG.PERS" => "https://t.me/",
"VK.PERS" => "https://vk.com/id",
"VK.GROUP" => "https://vk.com/group"
);
$buffer = ob_get_contents();
$buffer = str_replace("{{ LINK.CONTACT }}",$_buf["CONTACT"],$buffer);
$buffer = str_replace("{{ LINK.USLUGI }}",$_buf["SERVICE"],$buffer);
$buffer = str_replace("{{ EMAIL }}",$_buf["EMAIL"],$buffer);
ob_end_clean();
echo $buffer;
while(list($name,$val)){
//if(is_string($val)) {
// $buffer = str_replace('{{ '.$_buf[$name].' }}',$buffer);
//}
}
$matching_cells = array();
foreach ($buffer as $key => $value){
$matching_cells[$value] = $key;
}
$matching_cells = array();
foreach ($_buf as $key => $value){
$pref = "{{ ";
$posf = " }}";
if (strpos($pref.$key.$posf, $buffer) !== false) {
//echo 'true';
$buffer = str_replace("{{ ".$key." }}",$_buf[$key],$buffer);
}
}
ob_end_clean();
echo $buffer;
$_buf = array(
"LINK.USLUGI" => "/page/uslugi",
"LINK.CONTACT" => "/contact",
"EMAIL" => "email@domain.zone",
"TG.CANNEL" => "https://t.me/cannel",
"TG.PERS" => "https://t.me/",
"VK.PERS" => "https://vk.com/id",
"VK.GROUP" => "https://vk.com/group"
);
$buffer = ob_get_contents();
foreach($_buf as $k => $v)
{
$buffer = str_replace("{{ {$k} }}", $v, $buffer);
}
ob_end_clean();
echo $buffer;
$buffer = str_replace(
["{{ LINK.CONTACT }}","{{ LINK.USLUGI }}","{{ EMAIL }}"],
[$_buf["CONTACT"],$_buf["SERVICE"],$_buf["EMAIL"]],
$buffer);
[
"{{ LINK.CONTACT }}"=>"CONTACT",
"{{ LINK.USLUGI }}"=>"SERVICE",
"{{ EMAIL }}"=>"EMAIL",
]
и заменять его с помощью preg_replace_callback<?=$_BUF["EMAIL"]; ?>
, и тебе останется только include($template_name.".php"), подготовив перед этим содержимое $_BUF