March 9, 2013
how do i replace certain words in a sentence with php
Question by Imtiaz
Suppose I have this sentence: “The president obama came back to america from africa with his family”.
How do I replace “obama” with “bush”?
Answer by Starx
Using str_replace() functions:
$sentence = "The president obama came back to america from africa with his family";
$changed = str_replace("obama", "bush", $sentence);