I want to replace variables in text so that a user can set a custom date format.
In the simplest example, they can do this....
$text = 'The date today is {{current_date|Y-m-d}} isnt it';
$text = preg_replace('/{{current_date\|(.*)}}/', date("$1"), $text);
echo $text;
But this returns...
The date today is Y-m-d isnt it
But I want it to return....
The date today is 2020-07-10 isnt it
So the date is not being formatted. Any ideas what I'm doing wrong?