如何在PHP中从字符串中删除带有超链接的单词


How to remove words with hyperlinks from a string in PHP?

我需要一些帮助来删除PHP中包含超链接的单词。示例:

I was here dumb*

*具有超链接

我希望它是这样的:

I was here

dumb

有人能帮我吗?谢谢

编辑

我将加载"此页面",然后删除所有包含超链接的单词。示例:"LYSSNA,BILD SVENSKA/BILD FINSKA"

function findAndReplace($arr) {
    return '<strong>'.$arr[1].'</strong>';
}
$inputText = 'Why use <a href="#"  style="padding-left:5px"> PHP </a>?';
echo "<br />Input is: <br />";
echo $inputText;
$returnText = preg_replace_callback('@<a(?:.*)>(.*)</a>@isU', 'findAndReplace', $inputText);
echo "<br /><br />Output will be: <br />";
echo $returnText;

来源:http://php-opensource-help.blogspot.com/2010/10/how-to-remove-hyperlink-from-string.html

编辑

自从你编辑了你的原始帖子:尝试:

$new_string=preg_replace ("/<a.*>/i","",$string);

我认为这应该有效:

$string_without_hyperlinks = preg_replace('/<a's.*?>.*?<'/a>/s', '', $string);