i want to wrote a simple template engine
i have a html template file :
<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
<loop "loop_name">
content
<loop "loop_name2">
content2
</loop "loop_name2">
</loop "loop_name">
</body>
</html>
i need to find all loops and subloops with regular expression and replace them with my predefined php variables
i wrote this but i know this is wrong way
preg_match_all("/\<loop \"(.*)\"\>(.*)\<\/loop \"(.*)\"\>/", $template_file_text, $matches);
print_r($matches);
any answers will be appreciated