Foreground: I have this project I'm working on which uses email templates stored in database, each email body contain several shortcodes in the pattern {{$shortcode}}
.
Problem: Currently there is an admin setting for changing email template body. During edit, I want to add a Hint Notice to the person making the edit displaying the allowed shortcodes.
E.g You are editing XYZ template, the allow shortcodes are {{$shortcode1}}, {{$shortcode2}}, and {{$shortcode3}}
What I Want to do: The website has several email template with varying shortcodes, and the templates are prone to be changed or new once added.
To avoid going to each template and listing out each shortcode it has, In the controller, I want to check for the shortcodes in the template, extract them and pass them into the view.
E.g
$message = 'Hello {{$first_name}}, you have requested to change your password, your reset link is {{$link}}';
$shortcodes = explode(' ', $message);
if I dd($shortcodes)
, I get this array
0 => "Hello"
1 => "{{$first_name}},"
2 => "you"
3 => "have"
4 => "requested"
5 => "to"
6 => "change"
7 => "your"
8 => "password,"
9 => "your"
10 => "reset"
11 => "link"
12 => "is"
13 => "{{$link}}"
Now I want to get all the words starting with {{$
in the above array, is this possible ?