Instead of the array return type use component parameter PHP_URL_HOST to get the host part from the URL as string. This avoids an undefined index warning if host part could not be found.