public function countryFromURL($entityid) { try { $pu = parse_url($entityid, PHP_URL_HOST); if (!empty($pu)) { $rh = strrev($pu); DiscoUtils::debug('Looking up TLD : ' . $rh); foreach ($this->countryTLDs as $domain => $country) { if (DiscoUtils::prefix($domain, $rh)) { DiscoUtils::debug('Looking up TLD : ' . $rh . ' matched ' . $country); return $country; } } DiscoUtils::debug('Looking up TLD : ' . $rh . ' DID NOT MATCH any'); } } catch (Exception $e) { } return null; }