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

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

  2. <tfoot id='dgbg6'></tfoot>

        <bdo id='dgbg6'></bdo><ul id='dgbg6'></ul>

      在 PHP 中的斜杠后从 URL 中获取最后一个单词

      Get last word from URL after a slash in PHP(在 PHP 中的斜杠后从 URL 中获取最后一个单词)
      <tfoot id='Tksi6'></tfoot>
        <bdo id='Tksi6'></bdo><ul id='Tksi6'></ul>

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

          <tbody id='Tksi6'></tbody>

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

                本文介绍了在 PHP 中的斜杠后从 URL 中获取最后一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要从 URL 中获取最后一个词.例如,我有以下网址:

                I need to get the very last word from an URL. So for example I have the following URL:

                http://www.mydomainname.com/m/groups/view/test

                我只需要使用 PHP 进行测试",别无其他.我试图使用这样的东西:

                I need to get with PHP only "test", nothing else. I tried to use something like this:

                $words = explode(' ', $_SERVER['REQUEST_URI']);
                $showword = trim($words[count($words) - 1], '/');
                echo $showword;
                

                它对我不起作用.你能帮我吗?

                It does not work for me. Can you help me please?

                非常感谢!!

                推荐答案

                通过使用正则表达式:

                preg_match("/[^/]+$/", "http://www.mydomainname.com/m/groups/view/test", $matches);
                $last_word = $matches[0]; // test
                

                这篇关于在 PHP 中的斜杠后从 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() 文件不起作用?)

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

                    <tbody id='IHMK1'></tbody>
                  <legend id='IHMK1'><style id='IHMK1'><dir id='IHMK1'><q id='IHMK1'></q></dir></style></legend>
                    <bdo id='IHMK1'></bdo><ul id='IHMK1'></ul>