1. <small id='b2sW4'></small><noframes id='b2sW4'>

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

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

      1. <legend id='b2sW4'><style id='b2sW4'><dir id='b2sW4'><q id='b2sW4'></q></dir></style></legend>
      2. <tfoot id='b2sW4'></tfoot>
      3. 提交表单时从 URL 中删除 %5B%5D

        Remove %5B%5D from URL when submitting form(提交表单时从 URL 中删除 %5B%5D)
          <legend id='yPKXn'><style id='yPKXn'><dir id='yPKXn'><q id='yPKXn'></q></dir></style></legend>
              <tbody id='yPKXn'></tbody>
              • <bdo id='yPKXn'></bdo><ul id='yPKXn'></ul>
                <tfoot id='yPKXn'></tfoot>

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

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

                1. 本文介绍了提交表单时从 URL 中删除 %5B%5D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我提交一个包含多个同名复选框的表单时,我得到一个如下所示的 URL:www.mysite.com/search.php?myvalue%5B%5D=value1&myvalue%5B%5D=value2

                  When I submit a form with multiple checkboxes that have the same name I get a URL that looks something like this: www.mysite.com/search.php?myvalue%5B%5D=value1&myvalue%5B%5D=value2

                  有什么办法可以删除 %5B%5D 以使 URL漂亮",例如 htaccess?

                  Is there someway that I can remove the %5B%5D to make the URL "pretty", with something like htaccess?

                  代码:

                  <form>
                       <input type="checkbox" name="myvalue[]" value="value1">
                       <input type="checkbox" name="myvalue[]" value="value2">
                  </form>
                  

                  推荐答案

                  有什么办法可以删除 %5B%5D 以使 URL漂亮",例如 htaccess?

                  没有.[] 是 URL 中的保留字符,因此它们绝对需要URL 编码.

                  No. The [] are reserved characters in URLs, so they definitely need to be URL-encoded.

                  如果使用 POST 不是一个选项,考虑到它是一个搜索表单,这是有道理的,最好的办法是给它们每个一个不同的名称,值为 1 左右.

                  If using POST is not an option, which makes sense given that it's a search form, your best bet is to just give them each a different name with a value of 1 or so.

                  <form>
                      <input type="checkbox" name="option1" value="1" />
                      <input type="checkbox" name="option2" value="1" />
                  </form>
                  

                  或者,如果你真的坚持它们具有相同的名称,那么你应该自己提取查询字符串,而不是依赖 PHP 特定的特性,即在获取带有 [] 的参数时返回一个数组代码>名称中的后缀.

                  Or, if you really insist in them having the same name, then you should be extracting the query string yourself instead of relying on the PHP specific feature of returning an array when obtaining a parameter with a [] suffix in the name.

                  $params = explode('&', $_SERVER['QUERY_STRING']);
                  
                  foreach ($params as $param) {
                      $name_value = explode('=', $param);
                      $name = $name_value[0];
                      $value = $name_value[1];
                      // ... Collect them yourself.
                  }
                  

                  这样您就可以继续使用不带括号的名称.

                  This way you can just keep using the braceless name.

                  <form>
                      <input type="checkbox" name="option" value="option1" />
                      <input type="checkbox" name="option" value="option2" />
                  </form>
                  

                  这篇关于提交表单时从 URL 中删除 %5B%5D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='4Z8S4'></tfoot>

                2. <legend id='4Z8S4'><style id='4Z8S4'><dir id='4Z8S4'><q id='4Z8S4'></q></dir></style></legend>
                      <bdo id='4Z8S4'></bdo><ul id='4Z8S4'></ul>

                          <tbody id='4Z8S4'></tbody>

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

                            <small id='4Z8S4'></small><noframes id='4Z8S4'>