ManOfSpear Posted July 8, 2009 Share Posted July 8, 2009 Hey guys, I'm very new to PHP & Regex. I was wondering if it's possible to extract all possible URL's from a string and add it to an array. If anyone can help me I would be very grateful. Thanks. Link to comment https://forums.phpfreaks.com/topic/165122-solved-extract-all-urls-from-a-text/ Share on other sites More sharing options...
.josh Posted July 8, 2009 Share Posted July 8, 2009 preg_match_all('~https?://[^"\'\s]+~i',$string,$links); echo "<pre>"; print_r($links); Link to comment https://forums.phpfreaks.com/topic/165122-solved-extract-all-urls-from-a-text/#findComment-871019 Share on other sites More sharing options...
ManOfSpear Posted July 8, 2009 Author Share Posted July 8, 2009 preg_match_all('~https?://[^"\'\s]+~i',$string,$links); echo "<pre>"; print_r($links); Thank you my friend, it managed to get every single link which is amazing since every other regex I have tried failed badly. Link to comment https://forums.phpfreaks.com/topic/165122-solved-extract-all-urls-from-a-text/#findComment-871268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.