如何将这些代码从preg_replace()替换为preg_replace_callback()?
$search_array = array();
$replace_array = array();
$search_array[] = '~\{\$([^[<].*?)\[\'([^[<].*?)\'\]\[\'([^[<].*?)\'\]\}~';
$replace_array[] = '<?php echo $DHGS->_CONF[\'template\'][\'\\1\'][\'\\2\'][\'\\3\']; ?>';
$search_array[] = '~\{\$([^[<].*?)\[([^[<].*?)\]\[([^[<].*?)\]\}~';
$replace_array[] = '<?php echo $DHGS->_CONF[\'template\'][\'\\1\'][\'\\2\'][\'\\3\']; ?>';
$search_array[] = '~\{\$([^[<].*?)\[\'([^[<].*?)\'\]\}~';
$replace_array[] = '<?php echo $DHGS->_CONF[\'template\'][\'\\1\'][\'\\2\']; ?>';
$search_array[] = '~\{\$([^[<].*?)\[([^[<].*?)\]\}~';
$replace_array[] = '<?php echo $DHGS->_CONF[\'template\'][\'\\1\'][\'\\2\']; ?>';
$search_array[] = '~\{\$([^[<].*?)\}~';
$replace_array[] = '<?php echo $DHGS->_CONF[\'template\'][\'\\1\']; ?>';
$search_array[] = '~\{template}([^[<].*?){/template}~';
$replace_array[] = '<?php $this->display(\'\\1\'); ?>';
$search_array[] = '~\{include}([^[<].*?){/include}~';
$replace_array[] = '<?php include(\\1); ?>';
$search_array[] = '~\{info_row}([^[<].*?){/info_row}~';
$replace_array[] = '<?php $this->info_row(\'\\1\'); ?>';
$search_array[] = '~\{get_hook}([^[<].*?){/get_hook}~';
$replace_array[] = '<?php $this->get_hooks_template(\'\\1\'); ?>';
//////////
$string = preg_replace($search_array,$replace_array,$string);
上面的代码给出了不建议使用的警告。
如何从preg_replace转换为preg_replace_callback! 我尝试进行转换,但这是一个复杂的过程..