Multiple HTTP GET parameters with the same identifier

前端 未结 5 814
孤独总比滥情好
孤独总比滥情好 2020-12-03 14:47

Let\'s say I am getting requests such as:

http://www.example.com/index.php?id=123&version=3&id=234&version=4

Is it possible to extra

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 15:17

    Assuming you have some control over the request, suffix the name with [] and PHP will generate arrays instead of dropping all but one.

    http://www.example.com/index.php?id[]=123&version[]=3&id[]=234&version[]=4
    

    Since they are pairs you'll probably want to fix the order they appear in using indexes.

    http://www.example.com/index.php?id[0]=123&version[0]=3&id[1]=234&version[1]=4
    

提交回复
热议问题