<tfoot id='jYTPe'></tfoot>

    <small id='jYTPe'></small><noframes id='jYTPe'>

    <i id='jYTPe'><tr id='jYTPe'><dt id='jYTPe'><q id='jYTPe'><span id='jYTPe'><b id='jYTPe'><form id='jYTPe'><ins id='jYTPe'></ins><ul id='jYTPe'></ul><sub id='jYTPe'></sub></form><legend id='jYTPe'></legend><bdo id='jYTPe'><pre id='jYTPe'><center id='jYTPe'></center></pre></bdo></b><th id='jYTPe'></th></span></q></dt></tr></i><div id='jYTPe'><tfoot id='jYTPe'></tfoot><dl id='jYTPe'><fieldset id='jYTPe'></fieldset></dl></div>

      1. <legend id='jYTPe'><style id='jYTPe'><dir id='jYTPe'><q id='jYTPe'></q></dir></style></legend>

        • <bdo id='jYTPe'></bdo><ul id='jYTPe'></ul>

        如果找到子域,则从 url 字符串中删除子域

        Delete subdomain from url string if subdomain is found(如果找到子域,则从 url 字符串中删除子域)
          <bdo id='zJRPS'></bdo><ul id='zJRPS'></ul>

            <small id='zJRPS'></small><noframes id='zJRPS'>

          • <tfoot id='zJRPS'></tfoot>

              <legend id='zJRPS'><style id='zJRPS'><dir id='zJRPS'><q id='zJRPS'></q></dir></style></legend>
                <tbody id='zJRPS'></tbody>

                1. <i id='zJRPS'><tr id='zJRPS'><dt id='zJRPS'><q id='zJRPS'><span id='zJRPS'><b id='zJRPS'><form id='zJRPS'><ins id='zJRPS'></ins><ul id='zJRPS'></ul><sub id='zJRPS'></sub></form><legend id='zJRPS'></legend><bdo id='zJRPS'><pre id='zJRPS'><center id='zJRPS'></center></pre></bdo></b><th id='zJRPS'></th></span></q></dt></tr></i><div id='zJRPS'><tfoot id='zJRPS'></tfoot><dl id='zJRPS'><fieldset id='zJRPS'></fieldset></dl></div>

                  本文介绍了如果找到子域,则从 url 字符串中删除子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个这样的域数组:

                  I have an array of domains like this:

                  domain.com
                  second.com
                  www.third.com
                  www.fourth.fifth.com
                  sixth.com
                  seventh.eigth.com
                  

                  我想要的是一个只返回主机的函数.没有子域.

                  what I want is a function to return me the host only. Without subdomain.

                  这段代码是我到目前为止获取主机名的代码:

                  This code is what i have so far for getting the hostname:

                  $parse = parse_url($url);
                  $domain = $parse['host'];
                  

                  但这仅返回:

                  domain.com
                  second.com
                  third.com
                  fourth.fifth.com
                  sixth.com
                  seventh.eigth.com
                  

                  不过我需要这个输出:

                  domain.com
                  second.com
                  third.com
                  fifth.com
                  sixth.com
                  eigth.com
                  

                  推荐答案

                  function giveHost($host_with_subdomain) {
                      $array = explode(".", $host_with_subdomain);
                  
                      return (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : "").".".$array[count($array) - 1];
                  }
                  

                  这篇关于如果找到子域,则从 url 字符串中删除子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                  • <bdo id='MYIOU'></bdo><ul id='MYIOU'></ul>

                    <legend id='MYIOU'><style id='MYIOU'><dir id='MYIOU'><q id='MYIOU'></q></dir></style></legend>
                  • <i id='MYIOU'><tr id='MYIOU'><dt id='MYIOU'><q id='MYIOU'><span id='MYIOU'><b id='MYIOU'><form id='MYIOU'><ins id='MYIOU'></ins><ul id='MYIOU'></ul><sub id='MYIOU'></sub></form><legend id='MYIOU'></legend><bdo id='MYIOU'><pre id='MYIOU'><center id='MYIOU'></center></pre></bdo></b><th id='MYIOU'></th></span></q></dt></tr></i><div id='MYIOU'><tfoot id='MYIOU'></tfoot><dl id='MYIOU'><fieldset id='MYIOU'></fieldset></dl></div>
                  • <tfoot id='MYIOU'></tfoot>

                        <small id='MYIOU'></small><noframes id='MYIOU'>

                            <tbody id='MYIOU'></tbody>