Search the Community
Showing results for tags 'url extraction'.
-
Hy guys. I'm busting my head with this for whole day. I try to extract the first url that is written in my content (wordpress post). http://soundcloud.com/seq_dragos-1/survivor-eye-of-the-tiger [ By Survivor | <a href="http://www.lyrics007.com/Survivor%20Lyrics/Eye%20Of%20The%20Tiger%20Lyrics.html" target="_blank">Lyrics</a> | <a href="http://www.amazon.com/The-Rocky-Story-Soundtrack-Anthology/dp/B00000HZY2/ref=sr_1_1?ie=UTF8&qid=1353265582&sr=8-1&keywords=the+rocky+story" target="_blank">Get the album</a> ] So, I have this URL I want to extract: http://soundcloud.co...ye-of-the-tiger on a first line. I tried dozens of solutions. From regex and preg_match to parse_url... At the moment I have this code: unction parseAudio($path){ $parsedUrl = parse_url($path); if($parsedUrl['host'] == 'soundcloud.com' || $parsedUrl['host'] == 'www.soundcloud.com'){ // for soundcloud $embedUrl = parse_url($path, PHP_URL_PATH); echo "http://soundcloud.com$embedUrl"; } } This code kind of does what I want. I get this: <iframe width="580" height="435" src="http://soundcloud.com/seq_dragos-1/survivor-eye-of-the-tiger____[ By Survivor | <a href="http://www.lyrics007.com/Survivor%20Lyrics/Eye%20Of%20The%20Tiger%20Lyrics.html" target="_blank">Lyrics</a> | <a href="http://www.amazon.com/The-Rocky-Story-Soundtrack-Anthology/dp/B00000HZY2/ref=sr_1_1" frameborder="0" allowfullscreen></iframe> Problem is that path doesn't stop after URL. It continues on to the text. What can be done with this? Please, if anybody has any idea, share it. Thank you!