query("//a[@rel='noopener']") as $result) { $image = $xpath->evaluate(".//img", $result)[0]; if ($image) { $encoded_url = $result->getAttribute("href"); $encoded_url_split1 = explode("==/", $encoded_url)[1]; $encoded_url_split2 = explode("?position", $encoded_url_split1)[0]; $real_url = urldecode(base64_decode($encoded_url_split2)); $real_url = check_for_privacy_frontend($real_url); $alt = $image->getAttribute("alt"); $thumbnail = urlencode($image->getAttribute("src")); array_push($results, array ( "thumbnail" => urldecode(htmlspecialchars($thumbnail)), "alt" => htmlspecialchars($alt), "url" => htmlspecialchars($real_url) ) ); } } return $results; } function print_image_results($results) { echo "