I have several variables like these:
$foo = '123';
$bar = 'bqwe';
I need to replace {$foo}
and {$bar}
in a string with the variables.
preg_replace('~\{\$(.*)?\}~sU', ${'\\1'}, $string);
This doesn't work.
PS: The regex might not be correct. I haven't tested it with several variables like {$asd}
{$bbb}
. I am testing with one variable now.