swamp Posted July 2, 2009 Share Posted July 2, 2009 Hi there, Could anyone give me a hand with this? I need to extract an image from a remote URL (Just the first image on the site).. so if $url = 'http://www.bbc.co.uk' it would grab the first image it finds on the site. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/164519-solved-extract-image-from-url/ Share on other sites More sharing options...
Adam Posted July 2, 2009 Share Posted July 2, 2009 You can use file_get_contents() to get the source code, then use preg_match() to locate the first image. The pattern would be something like: <img[^\bsrc\b]+src="(.+?)"[^>]+> Quote Link to comment https://forums.phpfreaks.com/topic/164519-solved-extract-image-from-url/#findComment-867754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.