如何从preg_match_all的结果中删除锚标记?

时间:2015-02-06 01:17:43

标签: php file-get-contents preg-match-all

通过使用下面的代码,我得到类似的结果,但我想删除href标记。由于我的记录存储在一个数组中,

<a href="http://www.example.com">Title</a>

这样的解决方案
 preg_replace("/<a>(.+)<\/a>/", "$1", $title); 

不起作用并回应“数组”。我想剥离所有<a>标签并使其仅回显标题。我怎样才能实现它?我不擅长正则表达式,所以我卡住了。

代码:

for ($i = 0; $i < 4; $i++) {
        $site = file_get_contents("http://www.example.com/index.php?route=product/?_208&filter=1&page=10");
        preg_match_all('@<div class="rand"><a href="http://www.example.com/content/(.*?)/(.*?).html">(.*?)</a></div>@', $site, $title);
        preg_replace("/<a>(.+)<\/a>/", "$1", $title); 

        echo $title[2][$i] . "<br>";
    }

0 个答案:

没有答案