How to get the first subdomain with PHP?

前端 未结 5 833
广开言路
广开言路 2020-12-11 23:10

I have a static domain of dev.example.com with wildcard subdomains like so *.dev.example.com.

I need to detect the name of the current wild

5条回答
  •  北海茫月
    2020-12-11 23:20

    $domain = 'sub.dev.example.com';
    $tmp = explode('.', $domain);
    $subdomain = current($tmp);
    print($subdomain);     // prints "sub"
    

提交回复
热议问题