I want to make a (template)system so I need to replace tags for a value. The template is stored in a file called 'template.tpl' and contains the following:
{title}
{description}
{userlist}
{userid} is the id of {username}
{/userlist}
I have the following PHP script to rewrite the tags:
$template = file_get_contents('template.tpl');
$template = preg_replace('/{title}/', 'The big user list', $template);
$template = preg_replace('/{description}/', 'The big storage of all the users', $template);
Now I want to expand the script so I can rewrite the {userlist}. I have the following array with data:
$array = array(
1 => "Hendriks",
2 => "Peter"
);
How can I create a script that returns for example the following output?
The big user list
The big storage of all the users
1 is the id of Hendriks
2 is the id of Peter
I hope I have explained it as clearly as possible.