Have a string: $str = "Hello, {{first_name}} {{last_name}}!";
And variables $first, $last...
in array
$trans = array("{{first_name}}" => $first, "{{last_name}}" => $last, "{{cart}}" => $crt1, "{{phone}}" => $phone, "{{adds}}" => $addr, "{{order_id}}" => $order_id);
How to replace {{first_name}}->$first
, {{last_name}}->$last
Here what i did:
function replace_str($str, $trans)
{
$subj = strtr($str, $trans);
return $subj;
}
$cart = replace_str($str,$trans);
But strtr
doesn't work with cyrillic (utf-8)