PHP Strip string of first url and report results

askfind

New Member
\[code\]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>\[/code\]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 \[code\]<a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw">www.youtube.com/watch?v=2bP9tRhJRTw</a>\[/code\]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:\[code\]$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>";\[/code\]THANK YOU FOR YOUR HELPNOTE: i apologize if I've used the wrong terms.
 
Back
Top