I want to strip away hyperlinks, so only the text remains. So that
<a href='www.mysite.com/directory/'>Click Here For My Site</a>
Simply becomes
Click Here For My Site
I have this so far and it works:
$content = preg_replace('#<a.*>(.*)</a>开发者_如何学运维#isU', "$1", $content);
HOWEVER, I only want to strip the hyperlink away IF the hyperlink contains the specific test 'directory' in it.
In that case, the link below, which does not contain the word 'directory', would NOT be stripped of it's hyperlink.
<a href='www.mysite.com/FORUM/'>Click Here For My Site</a>
I cannot figure out how to do this! Whatever I try doesn't seem to work... :(
$content = preg_replace('/<a[^>]+directory[^>]*>(.*)<\/a>/isU', "$1", $content);
This will grab the text in the hyperlink as long as there id the word "Directory" in the opening <a>
tag
精彩评论