preg_replace的调用问题 本帖最后由 darenwuorg 于 2010-12-07 17:20:09 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你没把你的$str打出来看看!写的正则也是错误的! 怎么错误了, 我不太清楚,本人刚刚接触php! /<a href="(.*)">(.*)<\/a>/isU 大虾,如何把\\2调出来,当$str2用? preg_replace 只会得到字符串用 preg_match得到的数组[1] 会是你要的结果 preg_replace 只会得到字符串用 preg_match得到的数组[2] 会是你要的结果<?php$str=preg_replace('|<a href="(.*)">(.*)</a>|isU','<a href="test.php?id=\\1">\\2</a>',"<a href=\"abc\">abcdefg</a>");print($str);$str1=preg_match('|<a href="(.*)">(.*)</a>|isU',"<a href=\"abc\">abcdefg</a>",$str2);print_r($str2);?> php 安装imagemagick、MagickWand 问题 急~~ 关于调用amazon MWS提供的openapi的问题 请问在APMServ5.2.0下如何安装pear 我想去除掉这部分字符串,怎么弄? 分享个chm文档的网址 php跟IBM是什么关系? 再求 正则表达式 index.php?a=addsite --> addsite.html 要求a=addsite 必需为url结尾。 搜索查询,与数组有关... php中怎么样才可以跳转页面?像论坛回贴后那种跳转一样? 菜鸟又来求教了 如何截取前三个数字或都文字 非ie是否可以读取本地文件资源
/<a href="(.*)">(.*)<\/a>/isU
用 preg_match
得到的数组[1] 会是你要的结果
用 preg_match
得到的数组[2] 会是你要的结果
<?php
$str=preg_replace('|<a href="(.*)">(.*)</a>|isU','<a href="test.php?id=\\1">\\2</a>',"<a href=\"abc\">abcdefg</a>");
print($str);
$str1=preg_match('|<a href="(.*)">(.*)</a>|isU',"<a href=\"abc\">abcdefg</a>",$str2);
print_r($str2);
?>