I’m working on a simple templating system. Basically I’m setting it up such that a user would enter text populated with special tags of the form: <== variableName ==>
When the system would display the text it would search for all tags of the form mentioned and replace the variableName with its corresponding value from a database result.
I think this would require a regular expression but I’m really messed up in REGEX here. I’m using php btw.
Thanks for the help guys.
A rather quick and dirty hack here:
Output:
Simply place your ‘variables’ in the variable array and they will be replaced.
The
emodifier to the regular expression tells it to eval the replacement, the[a-z]lets you name the “variables” using the characters a-z (you could use [a-z0-9] if you wanted to include numbers). Other than that its pretty much standard PHP.