Sure,
All I have now is:
$results = preg_replace('/\b' . $needle . '\b/i', $replace, $haystack);
I noticed further that this only works if the needle matches the full haystack. This is obviously unacceptable.
So, while 'hamburger' will be replaced, 'i want a hamburger' is not being replaced.
Literally, what this project is for is military acronyms (and there are a ton of them). So, a needle array would look like:
array('inf bn', 'inf div', 'ADA')
and a replace array would look like:
array('infantry battalion', 'infantry division', 'air defense artillery')
Even if I opted to use single terms, I am still having a problem getting those replaced. When I use the haystack '1st inf bn' nothing is replaced, even while searching for single terms 'inf' and 'bn'.
This is my first attempt at regular expressions, so I'm not surprised if I'm way off base. They confuse me.