I have multi-line string with some variables like $Item_#1_Value$, $Item_#2_Value$, and so on. I would like to replace (case in-sensitive) all these instances with real values, which is not a problem with str_ireplace().
The problem is I need to remove also all spaces which may (or may not) be adjacent to these variables. The other spaces, not adjacent to variables, I need to not touch.
For example:
If $item_#1_Value$ is 1234, so strings:
ABC$item_#1_Value$QWERT, ABC $ITEM_#1_VALUE$ QWERT, ABC $item_#1_Value$ QWERT all needs to be replaced to ABC1234QWERT.
I have understood it should be preg_replace(...) used instead of str_ireplace(...), but I cannot realize what regexp pattern should I use.