public static function getZipFromCity($city, $street) { //options for HTTP request $options = array('http' => array('header' => "Content-Type: application/x-www-form-urlencoded", 'method' => "GET", 'content' => http_build_query(array('city' => $city, 'street' => $street)))); //formulating HTTP request $context = stream_context_create($options); //loading of answer for HTTP request and parsing of requested html file $html = SimpleHtmlDom::file_get_html('http://psc.posta.sk/', false, $context); $zipMessageObject = $html->find('.zip'); //finding if (isset($zipMessageObject[0]->plaintext)) { $zip = $zipMessageObject[0]->plaintext; return $zip; } else { return "Nepodarilo sa najsť PSČ."; } }