Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alihoushyaripour's avatar

How to parse parameters with same key in get request ?!

Hi,

If client send an array parameter with get request, in QUERY_STRING received with as separate parameters with the same keys, how I validate it in request class ?! :/

0 likes
3 replies
Sergiu17's avatar

Hi, could you give an example? if there's the same key, maybe all values should be an array assigned to one key, example: ?key=value,another+value,one+more+value

alihoushyaripour's avatar

@Sergiu17

of course, for example:

http://127.0.0.1:8000/api/myroute?name=ali&attributes=atr1&attributes=atr2&attributes=atr3

Now when I read url 'attributes' parameter, give me just 'atr3' and other two value missed, but in

$_SERVER['QUERY_STRING']

can find those but exist in a string that is difficult to parse it because I don't know other parameters in what order send to server ...

36864's avatar

How are you attempting to access the request's attributes?

Please or to participate in this conversation.