Dustin013 Posted June 6, 2008 Share Posted June 6, 2008 I have a variable $regexp = "<a\s[^>]*href=(\"??)(http[^\" >]*?)\\webprod(.*)<\/a>"; That is pulling a link off a page and returning it with <a href="http://webprod.blah.filename.ext">Click to download</a>. What I need to do is take $regexp and turn it into simply the path without the HTML tags. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/108966-trim-down-variable-to-remove-html-tags-yet-keep-link/ Share on other sites More sharing options...
jonsjava Posted June 6, 2008 Share Posted June 6, 2008 I'm sure there's an easier way, but this is how I write things (hate preg) <?php $data = "<a href=\"http://webprod.blah.filename.ext\">Click to download</a>"; $new_data = str_replace("<a href=\"", "", $data); $new_data = str_replace("\">Click to download", "", $new_data); $new_data = str_replace("</a>", "", $new_data); print $new_data; Link to comment https://forums.phpfreaks.com/topic/108966-trim-down-variable-to-remove-html-tags-yet-keep-link/#findComment-559147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.