foreach($data as $key => $value) {
$string = preg_replace("#\{$key\}#su", $value, $string);
}
$string = 'Привет {name}, это твой номер - {phone} ?';
$data = [
'phone' => '223344',
'name' => 'test'
];
echo preg_replace_callback("/{(\w+)}/", function ($matches) use ($data) {
return @$data[$matches[1]];
}, $string);