Im working with wordpress and this function im using returns this or something that looks like this:
<li><a href="http://foo.com/wp-content/uploads/2011/07/picture.png">picture</a></li>
What Im trying to do is get the HREF from that tag and store it in a variable, so I can manipulate it easily. Then after i have the HREF info i want to discard of the <li>
and the <a>
tag.
I looked into the php function strip_tag()
and that doesn't do what i want.
If this is overly complicated i will just not include the work in the webpage, but if it can be done.. help would be great.
First of all, make sure no other function exists that returns the unformatted data.
If not, here's a quick and dirty regex to pull out the URL:
$str = '<li><a href="http://foo.com/wp-content/uploads/2011/07/picture.png">picture</a></li>';
preg_match('~\shref="([^"]++)"~', $str, $matches);
$url = $matches[1];