For a template engine, I'd like to subsitute the following :
Hi <var:user_name />
to
Hi Jeroen
when the variable user_name = "Jeroen".
I've come up with following pattern :
(<var:)([a-zA-Z0-9_])[ ](/>)
And I get "user_name" perfectly in my \2 for eregi_replace :
eregi_replace("(<var:)([a-zA-Z0-9_])[ ](/>)", "\2", $val);
Now, it isn't really what I want... I would like to do this :
eregi_replace("(<tag:)([a-zA-Z0-9_])[ ](/>)", ${"\2"}, $val);
but it isn't possible. I'd rather not parse the string after replacing, so anyone have an idea how to accomplish this?
so no eval(eregi_replace("(<tag:)([a-zA-Z0-9_])[ ](/>)", "\$\2", $val));
nx