<?php $string = 'The dog ate the cat and the dog ate the chimp'; $find = 'dog'; $array = ['duck', 'pig']; $count = 1; while ($array && $count) { $string = preg_replace("#$find#", array_shift($array), $string, 1, $count); } echo $string;
You have javascript disabled. You will not be able to edit any code.