I'm attempting to build a function that will get images from a URL and sort through the values in the array and save the ones that contain only the src of the image. If you use this function it will pull images with the tags as well as the image src.
What I am asking is how can I get the src of image from a given URL put into a simple array?
function getImagesFromURL($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
if(preg_match_all('!<img.*?src=\"(.*?)\".*?>!is', $ret, $images)){
print_r($images);
}
else {
return "No images found!";
}
}