ecshop中 “所有的” preg_replace()怎么替换成preg_replace_callback()。
例如:(1)$out="<?php\n".'$k='.preg_replace("/(\'\\$[^,]+)/e","stripslashes(trim('\\1','\...
例如:(1) $out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
(2)$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
(3)
foreach ($keys AS $lib)
{
$lib_pattern .= '|' . str_replace('/', '\/', substr($lib, 1));
}
$lib_pattern = '/{include\sfile=(' . substr($lib_pattern, 1) . ')}/';
/* 修改$reg_content中的内容 */
$GLOBALS['libs'] = $libs;
$reg_content = preg_replace_callback($lib_pattern, 'dyna_libs_replace', $reg_content); 展开
(2)$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se';
$replacement = "'{include file='.strtolower('\\1'). '}'";
$source = preg_replace($pattern, $replacement, $source);
(3)
foreach ($keys AS $lib)
{
$lib_pattern .= '|' . str_replace('/', '\/', substr($lib, 1));
}
$lib_pattern = '/{include\sfile=(' . substr($lib_pattern, 1) . ')}/';
/* 修改$reg_content中的内容 */
$GLOBALS['libs'] = $libs;
$reg_content = preg_replace_callback($lib_pattern, 'dyna_libs_replace', $reg_content); 展开
展开全部
写个PHP脚本,循环获取指定文件夹中的每个文件的内容,然后用str_replace替换一下,这样就可以了
追问
谢啦,已经改好啦
追答
请采纳我的答案?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询