texelate Posted November 21, 2006 Share Posted November 21, 2006 Can someone help me with the regular expressions to remove all the hyperlinks from some HTML but leave the text for thelink in there?Eg:$html = '<div>This is <a href="link.html">Link 1</a> and <a href="link.html" target="_blank">Link 2</a> etc</div>';. . . would become . . .'<div>This is Link 1 and Link 2etc</div>'Thanks. Link to comment https://forums.phpfreaks.com/topic/27952-remove-all-hyperlinks-from-html/ Share on other sites More sharing options...
Nicklas Posted November 21, 2006 Share Posted November 21, 2006 [code=php:0]echo preg_replace('/<a href[^<>]+>|<\/a>/s', '', $html);[/code] Link to comment https://forums.phpfreaks.com/topic/27952-remove-all-hyperlinks-from-html/#findComment-127877 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.