Is it a hack to send array in query parameters in get?
It's a non-standard addition to application/x-www-form-urlencoded (which wasn't all that clearly defined in the first place), so yes, it is a hack.
Whether it is a clever hack or an ugly hack is largely a matter of opinion. There are pros and cons.
Does other programming languages support this like PHP do?
Most languages don't have HTTP processing baked in at such a fundamental level. PHP started life as a library for doing CGI-style things with and it shows. You really should be looking at libraries for processing form data and not languages here.
Most will let you expand duplicate keys in query strings without requiring that the name include []
(which is verbose and hard to read) for it to work. The limitation of this is that you can't explicitly specify the array index in the data.
There are implementations of the PHP style though. body-parser lets you use that syntax when you specify extended: true
. Perl's PHP::ParseStr
implements it, although doesn't integrate it with code to extract the string from the request.
If yes then what is best practice to pass array in GET parameters?
If you're using PHP, then use PHP's syntax for it.