Skip to content

Instantly share code, notes, and snippets.

@deviationist
Created April 18, 2020 23:24
Show Gist options
  • Save deviationist/d3046e7bd12d9f561ad5ae9ce02feaff to your computer and use it in GitHub Desktop.
Save deviationist/d3046e7bd12d9f561ad5ae9ce02feaff to your computer and use it in GitHub Desktop.
Get a domain without its subdomain (taking ccSLD into consideration)
<?php
// composer require jeremykendall/php-domain-parser
require_once __DIR__ . '/vendor/autoload.php';
$manager = new Pdp\Manager(new Pdp\Cache(), new Pdp\CurlHttpClient());
$domain = $manager->getRules()->resolve('this.is.a.very.long.domain.co.uk');
var_dump($domain->getRegistrableDomain());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment