如何在PHP字符串中替换一组短标签,例如:
$return = "Hello %name%, thank you for your interest in the %product_name%. %representative_name% will contact you shortly!";
我将定义%name%为一个字符串,可以从数组或对象中获取,例如:
$object->name;
$object->product_name;
我知道我可以在字符串上多次运行str_replace,但我想知道是否有更好的方法。
谢谢。