I have some words in a paragraph and I want to replace all with different values using PHP preg_replace() function and I solving with following code snippet but not able to solve that one.
$str = "abc abc abc abc abc abc";
$strArr = ["xyz", "pqr", "mnl", "01j", "pqr", "lmn"];
$count = preg_match_all("/abc/is", $str, $matches);
for($i = 0; $i < $count; $i++) {
preg_replace('/abc"([^\\"]+)"/', $strArr[$i], $str);
}
// At the end I need to get like as following
$str = "xyz pqr mnl 01j pqr lmn";
It is replacing only one first occurrence.