I'm trying to extract the first occurence of a link that starts like this
https://encrypted-tbn3.gstatic.com/images?...
from the source code of a page. The link starts and ends with a ". Here is what I've got so far:
$search_query = $array[0]['Name'];
$search_query = urlencode($search_query);
$context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla compatible')));
$response = file_get_contents( "https://www.google.com/search?q=$search_query&tbm=isch", false, $context);
$html = str_get_html($response);
$url = explode('"',strstr($html, 'https://encrypted-tbn3.gstatic.com/images?'[0]))
However the output of $url is not the link I try to extract, but something very different. I have added an image.
Could anyone explain the output to me and how I would get the desired link? Thanks