I have a string, that can has simple templates. And I have an array with values for replacemenet. Currently I am doing it with loop. But I want to change it to preg_replace. Can you help me?
Example:
$values = array(
'id' => 120,
'name' => 'Jim'
);
$string = 'Hello <!name!>. Your ID is <!id!>';
$output = preg_replace(...); // Hello Jim. Your ID is 120
Also preg_replace should work not only with id and name, but with any other keys. Thanks.