Ok I have a str_replace and what I want to do, is take values from an array, and take the next piece to replace the word "dog" with. So basically I want the $string to read:
"The duck ate the cat and the pig ate the chimp"
<?php
$string = 'The dog ate the cat and the dog ate the chimp';
$array = array('duck','pig');
for($i=0;$i<count($array);$i++) {
$string = str_replace("dog",$array[$i],$string);
}
echo $string;
?>
This code just returns:
"The duck ate the cat and the duck ate the chimp"
I tried several things but nothing works. Anyone have any ideas?