preg_replace('/{get_(\w+)}/',$arr[$1], $content);
preg_replace_callback 可以回调函数,但是怎么把匹配到的,作为数组的索引,这个我找不到方法
preg_replace('/{get_(\w+)}/e','$arr["$1"]', $content);
$content = '{get_abc}';$arr['abc'] = 123;echo preg_replace('/{get_(\w+)}/e', '$arr["$1"]', $content);
$content = '{get_abc}';$arr['abc'] = 123;echo preg_replace_callback('/{get_(\w+)}/', 'back', $content);function back($m) { global $arr; return $arr[$m[1]];}
$content = '{get_abc}';$arr['abc'] = 123;echo preg_replace_callback('/{get_(\w+)}/', create_function('$m', 'global $arr; return $arr["$m[1]"];'), $content);
$content = '{get_abc}';$arr['abc'] = 123;echo preg_replace_callback('/{get_(\w+)}/', function($m) use($arr) { return $arr["$m[1]"];}, $content);显然第 3 种写法最清晰,但只在 php5.3 才开始支持