I've been experimenting with preg_replace() today, but I can't figure out how to replace words that are repeated. I can the first word replaced, but the same word right after that word is still output to the browser.
$string1 = '/[^a-zA-Z]+(the)[^a-zA-Z]+/i';
$string2 = 'ha';
$string3 = 'A the the joke';
echo preg_replace($string1, $string2, $string3);
What I'm trying to do is replace a word that a) has one or more characters in front of it (except letters) followed by b) the substring "the" followed by c) one or more characters that are not letters. What am I doing wrong?