recieve a list of URLs and return all image sources from it
function get_image_sources($urls) { // get the contents of the pages $pages = array_map('file_get_contents', $urls); // find all img tags $matches = preg_grep('/<img[^>]+>/i', $pages); // find the src attribute $matches = array_map(function($line) { preg_match('/src="([^"]+)"/', $line, $matches); return $matches[1]; }, $matches); return $matches; }