Thanks for your reply.
My issue here is that I'm looking for a solution to be much, much simpler than any PHP template solution I've found online, including yours, which BTW, is the best one of the ones I looked at.
I am looking at creating a "for dummies" system where my clients can add new pages and templates to their site without writing any code whatsoever or opening Dreamweaver. It's all a wysiwyg-thingamajig, and it works.
Currently, my template files are just standard .php or .html files with template markup in the following format:
<!--@@(1)-->
<!--@@TEXT(1)-->
These template tags will be parsed and replaced with database content, after the user have defined what image to place as image #1 in the current page, etc. I am also writing functions and GUI for uploading images, creating an image bank, text re-use and such, all to keep this very simple for my clients.
preg_match_all is slow you say - are there any other, faster ways to do what I want to do? I am currently using this regexp:
preg_match_all("/<!--@@(.)((.))-->/", $content, $regs);
...to fetch my tags and put the important stuff in the $regs array. Later I loop through the array and use a str_replace() to replace the content in the page with the database loaded stuff.
If anybody has any better ideas on how to do this, I'd be very greatful!
//Mans