I want to match two string and if any words match I want to add tag to them.
I tried something like below below code
$old = "one two three";
$new = "how is one related to two";
foreach (explode(" ", $old) as $str) {
$str .= str_replace($str, "<b>$new</b>", $str);
}
echo trim($str);
Exptected result how is <b>one</b> related to <b>two</b>.
Please suggest me some other way than looping if possible..If its not possible please tell me with looping.