טעיתי.. תיקון קוד:
PHP קוד:
preg_replace('/\{(.*?)\}/ei', 'print str_replace(\'{$1}\', $temp[\'$1\'], $text);', $text);
יש גם את האפשרות הזו:
PHP קוד:
echo preg_replace_callback('/\{(.*?)\}/i', function($varMatches) {
return $GLOBALS['temp'][$varMatches[1]];
}, $text);