且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取阵​​列参数进行查询字符串与PHP

更新时间:2023-02-24 08:53:41

您查询字符串,而应该是这样的:

  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