Yngvarr

Generation

generate functionSun, 19 Mar 2023

get tdl with domain

function get_tld($url) { $tld = ''; $parsed_url = parse_url($url); $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; if ($host == '') { return $tld; } $host_components = explode('.', $host); $tld_components = array_slice($host_components, -2); $tld = implode('.', $tld_components); return $tld; }

Questions about programming?Chat with your personal AI assistant