# $arg\_name as an array

**URL:** <https://www.ruby-forum.com/t/arg-name-as-an-array/241018>\
**Category:** NGINX\
**Created:** [May 9, 2014, 11:17am UTC](https://www.ruby-forum.com/t/arg-name-as-an-array/241018 "2014-05-09T11:17:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [May 9, 2014, 11:17am UTC](https://www.ruby-forum.com/t/arg-name-as-an-array/241018/1 "2014-05-09T11:17:36Z")

</div>

Hello,

Does it possible to use $arg\_name as an array?  
For example  
I’ve query string : ?opt[test]=1

I’d like to get value od opt[test] but $arg\_opt[test] doesn’t work.

Is there special syntax for that case?

Posted at Nginx Forum:

> **[$arg\_name as an array](https://forum.nginx.org/read.php?2,249982,249982#msg-249982)**
>
> Hello, Does it possible to use $arg\_name as an array? For example I've query string : ?opt\[test\]=1 I'd like to get value od opt\[test\] but $arg\_opt\[test\] doesn't work. Is there special syntax for that case?

---

<div class="post-metadata">

**Author:** ![beatnut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e95f7d/32.png) [@beatnut](https://www.ruby-forum.com/u/beatnut)\
**Post date:** [May 9, 2014, 11:55am UTC](https://www.ruby-forum.com/t/arg-name-as-an-array/241018/2 "2014-05-09T11:55:44Z")

</div>

On 9 May 2014 10:16, beatnut [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello,
> 
> Does it possible to use $arg\_name as an array?  
> For example  
> I’ve query string : ?opt[test]=1
> 
> I’d like to get value od opt[test] but $arg\_opt[test] doesn’t work.
> 
> Is there special syntax for that case?

Query strings arguments are just strings. Whatever encoding you layer  
on top of those strings, in order to be able to treat them as arrays,  
is entirely subjective: you could be using any one of a number of  
encodings. Nginx has no mechanism to deal with this in its vanilla  
setup, as far as I’m aware.

I don’t know how its embedded perl or lua modules might be /able/ to  
treat them, but you’d almost certainly have to /train/ them (at least  
trivially) in how to understand your specific encoding: semi-colon  
separated? Brackets of some kind? Some more densely packed binary  
encoding which you’ve then had to base64 encode because of HTTP? Nginx  
doesn’t know this, and doesn’t give you this functionality out of the  
box.

J

---

<div class="post-metadata">

**Author:** ![beatnut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e95f7d/32.png) [@beatnut](https://www.ruby-forum.com/u/beatnut)\
**Post date:** [May 9, 2014, 12:03pm UTC](https://www.ruby-forum.com/t/arg-name-as-an-array/241018/3 "2014-05-09T12:03:07Z")

</div>

On 9 May 2014 10:16, beatnut [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does it possible to use $arg\_name as an array?  
> For example  
> I’ve query string : ?opt[test]=1
> 
> I’d like to get value od opt[test] but $arg\_opt[test] doesn’t work.
> 
> Is there special syntax for that case?

This thread might be of interest:  
[http://forum.nginx.org/read.php?11,241016](http://forum.nginx.org/read.php?11,241016)

I haven’t tested it but it suggests that the syntax ${arg\_opt[test]}  
might  
do what you require.

–

This email, including attachments, is private and confidential. If you  
have  
received this email in error please notify the sender and delete it from  
your system. Emails are not secure and may contain viruses. No liability  
can be accepted for viruses that might be transferred by this email or  
any  
attachment. Any unauthorised copying of this message or unauthorised  
distribution and publication of the information contained herein are  
prohibited.

7digital Limited. Registered office: 69 Wilson Street, London EC2A 2BB.  
Registered in England and Wales. Registered No. 04843573.

---

<div class="post-metadata">

**Author:** ![beatnut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e95f7d/32.png) [@beatnut](https://www.ruby-forum.com/u/beatnut)\
**Post date:** [May 9, 2014, 12:04pm UTC](https://www.ruby-forum.com/t/arg-name-as-an-array/241018/4 "2014-05-09T12:04:58Z")

</div>

Note that this is not “treating $arg\_name as an array”, it’s simply  
allowing you to use the characters in a variable name - usually only  
a-z0-9\_ is allowed

On 9 May 2014 11:02, Matt G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> This thread might be of interest:  
> [http://forum.nginx.org/read.php?11,241016](http://forum.nginx.org/read.php?11,241016)
> 
> I haven’t tested it but it suggests that the syntax ${arg\_opt[test]} might  
> do what you require.

–  
_Matt G._  
API Developer

_T:_ +44(0)207 099 7777  
_E:_ [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
_W:_  
[www.7digital.com](http://www.7digital.com)[http://www.google.com/url?q=http%3A%2F%2Fwww.7digital.com&sa=D&sntz=1&usg=AFrqEzeLlO75mVeA-8Yi-niLjEpFokXaYA](http://www.google.com/url?q=http%3A%2F%2Fwww.7digital.com&sa=D&sntz=1&usg=AFrqEzeLlO75mVeA-8Yi-niLjEpFokXaYA)

–

This email, including attachments, is private and confidential. If you  
have  
received this email in error please notify the sender and delete it from  
your system. Emails are not secure and may contain viruses. No liability  
can be accepted for viruses that might be transferred by this email or  
any  
attachment. Any unauthorised copying of this message or unauthorised  
distribution and publication of the information contained herein are  
prohibited.

7digital Limited. Registered office: 69 Wilson Street, London EC2A 2BB.  
Registered in England and Wales. Registered No. 04843573.

---

<div class="post-metadata">

**Author:** ![beatnut](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e95f7d/32.png) [@beatnut](https://www.ruby-forum.com/u/beatnut)\
**Post date:** [May 9, 2014, 12:19pm UTC](https://www.ruby-forum.com/t/arg-name-as-an-array/241018/5 "2014-05-09T12:19:07Z")

</div>

Thanks for explanation.  
I’ll try with example above.

Posted at Nginx Forum:

> **[Re: $arg\_name as an array](https://forum.nginx.org/read.php?2,249982,249987#msg-249987)**
>
> Hello, Does it possible to use $arg\_name as an array? For example I've query string : ?opt\[test\]=1 I'd like to get value od opt\[test\] but $arg\_opt\[test\] doesn't work. Is there special syntax for that case?
