我有一个问题,如何重新排序GET变量。。解释起来很复杂,但我认为展示代码要好得多。
http://URL.com/?product_id=23&year=2013&seite=reporting&action=jahres&report=jahres
但我真的想要这样。
http://URL.com/?seite=reporting&action=jahres&report=jahres&product_id=23&year=2013
<input type="hidden" name="seite" value="reporting"/>
<input type="hidden" name="action" value="jahres"/>
<input type="hidden" name="report" value="jahres"/>
表单的动作只是页面的URL。
GET变量?seite=报告,<---这一点我需要始终站在所有其他变量的前面,我该怎么做?
谢谢你的帮助!
如果你自己在url中传递它们,那么你把它们按什么顺序放置并不重要。
这并不重要。您可以添加更多的查询字符串参数,也可以按任何顺序删除它们。然后使用$_GET["product_id"]
等访问它们并进行相应的处理。
GET
变量没有排序,您可以将它们按任何顺序放置,但仍然会得到相同的结果。
如果您有隐藏的输入,您可以在URL中对这些变量的视图进行排序,重新确定这些变量的位置,例如:
<input type="hidden" name="seite" value="reporting"/>
<input type="hidden" name="action" value="jahres"/>
<input type="hidden" name="report" value="jahres"/>
您可以这样做:
<form>
1. First Level in your form
<input type="hidden" name="seite" value="reporting"/>
2. Last level in your form the other variables hidden or not.
<input type="hidden" name="action" value="jahres"/>
<input type="hidden" name="report" value="jahres"/>
</form>
如果您想访问变量:
$seite = isset($_GET['seite']) ? $_GET['seite'] : null;
当你按下提交按钮时,表单会将第一个输入隐藏起来,在你的URL中获取,但这并不重要,只是为了炖汤!
您可以将GET变量放入数组中
$variables = Array (
[0] => $_GET['one']
[1] => $_GET['two']
[2] => $_GET['three']
);
然后在URL输出中一个接一个地回显它们
$url = "http://website.com/script.php?get1=" . $variables[0] . "&get2=" . $variables[1];