Jump to content

Trim down variable to remove html tags yet keep link?


Dustin013

Recommended Posts

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?

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;

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.