I have a map for substitute words:
$map = array( 'word1' => 'replacement1', 'word2 blah' => 'replacement 2',
I need to replace the words in a string. But replacement should only be done when the string is a word:
- It is not in the middle of any other ex word. textword1 will not be replaced by replacement1, as it is part of another token.
- Separators should be retained, but the words before / after them should be replaced.
I could split the regular expression string into words, but this does not work when values ββwith multiple tokens will be displayed (e.g. word2 blah).
source share