I have string like this in database (the actual string contains 100s of word and 10s of variable):
I am a {$club} fan
I echo this string like this:
$club = "Barcelona";
echo $data_base[0]['body'];
My output is I am a {$club} fan
. I want I am a Barcelona fan
. How can I do this?
Use
strtr
. It will translate parts of a string.For multiple values (demo):
Program Output: