'How to dynamically fill a text template with a user data

I'm working on this project where I want HR to create an offer letter template through a large text box with some blank spaces.

Then when the HR wants to send the offer letter to the employee, the blank spaces will automatically be filled with employee's data such as name, email, salary etc.

I'm thinking that the HR should add things like e.g '[name]', '[email]'. When creating the offer letter so maybe I can loop through it and fill the necessary information.

There's no code available since I've started working on it.

I want to ask if they is a better way of going about this or how should I go about the implementation of what I mentioned above?

Tech stack;

Laravel 8.7 PHP v8 MySQL innodb Apache



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source