从自定义标记获取内容并删除自定义标记无效

时间:2017-01-14 14:31:01

标签: php

我试图在<amazon></amazon>代码之间获取内容。

<amazon><a rel="nofollow"><img border="0" ></a><img width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</amazon>

我已经尝试使用正则表达式获取html inbetween标签。

 preg_match_all('/<amazon>(.*?)<\/amazon>/s', $string, $matches);
 $amazon = $matches[1];

但这不起作用。当我检查数据库时,它只是空白。

此外,我想删除<amazon></amazon>以及之间的所有内容。我试过正则表达式而且也没有工作。

 $string = preg_replace('~\<amazon\>(.+?)\</amazon\>~','',$string);

我如何解决?

0 个答案:

没有答案
相关问题