获取阵列参数进行查询字符串与PHP [英] Getting array param out of query string with PHP
问题描述
(注意:这是一个跟进到previous问题,<一个href=\"http://stackoverflow.com/questions/5974820/how-to-pass-the-array-values-on-query-string-in-php\">How在查询字符串中传递数组?,在那里我问了一下查询字符串中传递数组的标准方法。)
我现在有一些PHP code,它需要消耗该查询与字符串是什么样的查询字符串数组格式不PHP认了,我必须做什么特别的检索数组?
以下似乎不工作:
查询字符串:
?formparts = [A,B,C]
PHP:
$ myArray的= $ _GET [formparts];
回声将gettype($ myarray中)
结果:
字符串
您查询字符串,而应该是这样的:
formparts [] = A和?formparts [] = B和formparts [] = C
(NOTE: This is a follow up to a previous question, How to pass an array within a query string?, where I asked about standard methods for passing arrays within query strings.)
I now have some PHP code that needs to consume the said query string- What kind of query string array formats does PHP recognize, and do I have to do anything special to retrieve the array?
The following doesn't seem to work:
Query string:
?formparts=[a,b,c]
PHP:
$myarray = $_GET["formparts"];
echo gettype($myarray)
result:
string
Your query string should rather look like this:
?formparts[]=a&formparts[]=b&formparts[]=c
这篇关于获取阵列参数进行查询字符串与PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!