求助 php匹配替换多个指定内容里面的字符串 本帖最后由 alphapn2000 于 2011-05-05 11:24:32 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $s = <<< TEXT<?xml version="1.0" encoding="gb2312" ?> <rss version="2.0"><item><title>标题1</title><description><table> <tbody> <tr align="center"> <td><p>内容......</p></td> </tr> </tbody></table></description></item> <item><title>标题2</title><description><table> <tbody> <tr align="center"> <td><p>内容......</p></td> </tr> </tbody></table></description></item></rss>TEXT;$p = '/<(description)>(.*?)<\/\\1>/ise';$r = '"<$1>".htmlspecialchars("$2", ENT_NOQUOTES)."</$1>"';echo preg_replace($p, $r, $s);<?xml version="1.0" encoding="gb2312" ?> <rss version="2.0"><item><title>标题1</title><description><table> <tbody> <tr align="center"> <td><p>内容......</p></td> </tr> </tbody></table></description></item> <item><title>标题2</title><description><table> <tbody> <tr align="center"> <td><p>内容......</p></td> </tr> </tbody></table></description></item></rss> 请教高手 一下代码如何理解?array_filter session的作用域 再问下。为什么用smarty模板分离,css会有问题呢。 php语言如何做到安全性的? 极速论坛,添加了新的安全机制。测试中。请大家帮忙测试。 ftp上传文件太慢了,怎么解决呢? PHP连infomix ecshop这个url重写哪里出错了 js里的!![]如何让转化成PHP 利用音乐搜索器中的接口,请求音乐资源,返回是空的 phpmyadmin解压到web根目录,web根目录在哪,刚学的,不好意思都不懂。 网站首页打开很慢,请教是何原因
<?xml version="1.0" encoding="gb2312" ?>
<rss version="2.0">
<item>
<title>标题1</title>
<description>
<table>
<tbody>
<tr align="center">
<td><p>内容......</p></td>
</tr>
</tbody>
</table>
</description>
</item>
<item>
<title>标题2</title>
<description>
<table>
<tbody>
<tr align="center">
<td><p>内容......</p></td>
</tr>
</tbody>
</table>
</description>
</item></rss>
TEXT;$p = '/<(description)>(.*?)<\/\\1>/ise';
$r = '"<$1>".htmlspecialchars("$2", ENT_NOQUOTES)."</$1>"';
echo preg_replace($p, $r, $s);<?xml version="1.0" encoding="gb2312" ?>
<rss version="2.0">
<item>
<title>标题1</title>
<description>
<table>
<tbody>
<tr align="center">
<td><p>内容......</p></td>
</tr>
</tbody>
</table>
</description>
</item>
<item>
<title>标题2</title>
<description>
<table>
<tbody>
<tr align="center">
<td><p>内容......</p></td>
</tr>
</tbody>
</table>
</description>
</item></rss>