I am trying to replace multiple variables in a text.
I have For example this text:
This is an example text , my variables are:
%name%
%frontname%
%lastname%
%email%
No I want to replace each variable that is between the % % characters with {$variable}.
So my output looks like this:
This is an example text , my variables are:
{$name}
{$frontname}
{$lastname}
{$email}
The pattern I am trying to use is this :
$textResponder = preg_replace('#\%[^\%]+\%#', '{$$1}', $text);
But that is not working, as I get this as output: {$} {$} {$}. Does somebody know what the correct pattern would be?
Thanks in advance
Test here