又一个正则表达式问题 假如用<<<和>>>嵌套呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function htmlsp($matches){ $text = htmlspecialchars(nl2br($matches[1])).$matches[2].htmlspecialchars(nl2br($matches[3])); return $text;}function replace(){ $str = implode("",file("test.txt")); $p = "/(<!--.*)\[\[(.*?)\]\](.*-->)/i"; $r = "$1[<span>[$2]</span>]$3"; $str = preg_replace($p,$r,$str); $p = "/([^\[\]]*?)\[\[(.*?)\]\]([^\[\]]*?)/si"; $text = preg_replace_callback($p,htmlsp,$str); print $text;}replace(); sandyuk(冰の沙隆) 您好,好久没来CSDN了,复帖迟了,请见谅我的TXT文本只是举了一个例子,并不是固定的格式。function htmlsp($matches){ $text = htmlspecialchars(nl2br($matches[1])).$matches[2].htmlspecialchars(nl2br($matches[3])); return $text;}函数里不用数组常数索引可以吗? php网站自动安装是如何实现的?? 用php,怎样检测数据是否到达了客户端(浏览器)? PHP textarea 换行问题 dedecms 中的currentstyle是干什么用的? php做后台,怎么和前台结合? PHP 如何获取网址里的数据 关于PHP数据库的小问题 为什么不能传值?没反应呀+++++++ 怎样获取页面上指定的信息 wordpress 如何添加链接型文章标题? 关于网上支付程序接口 谁有用户注册系统的PHP源代码,高分求购!男女我用两个单选按钮,请问怎样写代码?
{
$text = htmlspecialchars(nl2br($matches[1])).$matches[2].htmlspecialchars(nl2br($matches[3]));
return $text;
}
function replace()
{
$str = implode("",file("test.txt"));
$p = "/(<!--.*)\[\[(.*?)\]\](.*-->)/i";
$r = "$1[<span>[$2]</span>]$3";
$str = preg_replace($p,$r,$str);
$p = "/([^\[\]]*?)\[\[(.*?)\]\]([^\[\]]*?)/si";
$text = preg_replace_callback($p,htmlsp,$str);
print $text;
}
replace();
我的TXT文本只是举了一个例子,并不是固定的格式。
function htmlsp($matches)
{
$text = htmlspecialchars(nl2br($matches[1])).$matches[2].htmlspecialchars(nl2br($matches[3]));
return $text;
}函数里不用数组常数索引可以吗?