Heim >Backend-Entwicklung >PHP-Tutorial >preg_replace_callback函数
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
$val = preg_replace_callback("/\[([^\[\]]*)\]/eis", function($match){ return str_replace('$','\$',$match)}, $val);
$val = preg_replace_callback( '/\[([^\[\]]*)\]/is', function ($matches) { return '.'.str_replace('$','\$',$matches[1]); }, $val );echo $val;
同理这个呢
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
同理这个呢
$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($ro) { return stripslashes(trim($ro[1],'\''));}, var_export($t, true)) . ";\n";
最后一处了 这里中间的代码 include哪一行不清楚怎么改
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';$replacement = "'{include file='.strtolower('\\1'). '}'";$source = preg_replace_callback($pattern, $replacement, $source);- -
最后一处了 这里中间的代码 include哪一行不清楚怎么改
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';$replacement = "'{include file='.strtolower('\\1'). '}'";$source = preg_replace_callback($pattern, $replacement, $source);- -
最后一处了 这里中间的代码 include哪一行不清楚怎么改
$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s';$replacement = "'{include file='.strtolower('\\1'). '}'";$source = preg_replace_callback($pattern, $replacement, $source);- -
$replacement = "'{include file='.strtolower('\\1'). '}'";非常感谢
$replacement = function ($matches) { return '{include file='.strtolower($matches[1]). '}';};