Russel Peter video: <a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw">www.youtube.com/watch?v=2bP9tRhJRTw</a> russel peters video blah blah. Turtles: <a href="http://turtles.com">turtles.com</a>
I have a string that contains text and and tags with enclosed urls like the above example.
I want to strip the out ONLY the first tag found
<a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw">www.youtube.com/watch?v=2bP9tRhJRTw</a>
and from that, strip out the url inside the href="".
But... i also want to be able store the text around the tag that is pulled out.
I'm looking for something like this as the end result after all the stripping:
$originalstring = "Russel Peter video: <a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw">www.youtube.com/watch?v=2bP9tRhJRTw</a> russel peters video blah blah. Turtles: <a href="http://turtles.com">turtles.com</a>";
$preurl = "Russel Peter video: ";
$atag = "<a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw">www.youtube.com/watch?v=2bP9tRhJRTw</a>";
$url = "http://www.youtube.com/watch?v=2bP9tRhJRTw";
$afterurl = " russel peters video blah blah. Turtles: <a href="http://turtles.com">turtles.com</a>";
THANK YOU FOR YOUR HELP
NOTE: i apologize if I've used the wrong terms.