I have map for replacement words:
$map = array(
'word1' => 'replacement1',
'word2 blah' => 'replacement 2',
//...
);
I need to replace words in string. But replacement should be executed only when string is word:
- It is not in the middle of some other word ex. textword1 will not be replaced with replacement1 because it is part of another token.
- Separators must be saved, but words before/after them should be replaced.
I could split string with regexp to words but this does not work when there will be mapped values with few tokens (like word2 blah).
See it