是否可以从相同$ _GET具有不同值的url中检索参数?
如 www.domain.com/?user=1&user=2
目前这只显示第二个列出的内容,所以如果我echo $_GET['user'],它会输出2
我似乎无法在SO上找到这个,所以如果我错过了,请告诉我.
谢谢你的帮助!
快速回答是否定的。
http://localhost/?user=1&user=2
Run Code Online (Sandbox Code Playgroud)
让你:
array
'user' => string '2' (length=1)
Run Code Online (Sandbox Code Playgroud)
但是,通过在查询中包含括号,如下所示:
http://localhost/?user[]=1&user[]=2
Run Code Online (Sandbox Code Playgroud)
您可以检索 $_GET['user'] 并返回以下内容:
array
'user' =>
array
0 => string '1' (length=1)
1 => string '2' (length=1)
Run Code Online (Sandbox Code Playgroud)