Yes you can do it with preg_replace(), but it's still a complex task. The if/else thing isn't too complicated, you could do it like this:
... but the loops will be more difficult.
Quote:
|
Which one is better and faster?
|
Well you're only providing your own example. But I think the "check" is redundant. I'm guessing it queries the database to see if it's there? So you're querying the database twice for the same thing?
Why not just:
...?
Quote:
|
I have one more question is it possible that I add sth (e.g: other template or var) to start or end of a template or var (ESP:var)?
|
I have no idea what you just said. Do you mean you want to merge templates?!
But anyway, why don't you just use Smarty? It does already what you want to do.