Ok. I'm trying to include files using a tag "{T.filename}". Here's my code: <?php $str = '{T.test} test {T.lawl}'; preg_replace("#{T.(.+?)}#is", include(\\1), $str); ?> PHP: I don't know how I would include it successfully. Any help? - JTD
Check out "Example #4 Using the 'e' modifier" on the preg_replace php.net page. That's what allows you to execute functions in preg_replace.
Could you please tell me how? I've been trying: $str = '{T.tester} hi'; preg_replace("/{T.(.+?)}/e", "file_get_contents(eval('\\1'))", $str); PHP: $str = '{T.tester} hi'; preg_replace("/{T.(.+?)}/e", "'.include('\\1').'", $str); PHP: $str = '{T.tester} hi'; preg_replace("/{T.(.+?)}/e", include("'\\1'")), $str); PHP: And many more variations. I still don't get it =S
This works on PHP 5: <?php function inc($match){ include($match[1]); } $str = '{T.test} test {T.lawl}'; echo preg_replace_callback('#{T\.(.+?)}#', inc, $str); ?> PHP: Rep would be appreciated Jay