After searching the web and trying to figure this out for hours, I give up and submit to you, my Regex overloards...
I am building a small templating engine (using Smarty is out of the question) and I need to do the following in PHP:
Read a variable from a database that contains the template code (I can do this, no prob of course)
Here is a very simple sample of what the template code stored in that variable might look like:
$templatecodevariable="<html>
<title>Hi this is my templating engine!</title>
<body>
<h2><templatecode>displaysomething()</templatecode></h2>
<p>
<templatecode>listsomething()</templatecode>
</p>
</body>
</html>";
What i need to do is go through this variable and send anything in between <templatecode> and </templatecode> off to a function (don't worry about what will happen there, i have that done) and then
replace the whole '<templatecode>displaysomething()</templatecode>' bit with the result of that function...
However it gets done, i need the final string in a var that i can then display on the screen...
No need to do any really advanced error or security checking (although ideas are welcome), I just need the basic way to do this, from there i can expand it.
Thanks so much, I'll be sure to share the final engine with you all when it's done...
-Stephen