V
V
Vitaly Peretyatko2013-04-25 16:34:29
Nginx
Vitaly Peretyatko, 2013-04-25 16:34:29

Variable variable name in NGINX?

Suppose there is such a config

location /test {
   set $var_test1 value1;
   set $var_test2 value2;
   set $index 1;

  echo $var_test$index; # ??? так не работает, надо чтоб вывело value1, тоесть значение переменной с индексом 1
}

There are several variables (in a real task they will be $cookie_.....) with different indices, there is a variable with an index. How to get the value of a variable with an index from another variable?
Since the values ​​I need are stored in Cookies, I tried to approach it from the other side - parse it with a regexp. But unfortunately, variables inside the regexp seem to be not allowed either ...
I would like to solve it using standard tools, use perl, lua or write my own module ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
joneleth, 2013-04-26
@viperet

there's no such thing

M
mayorovp, 2013-04-26
@mayorovp

Is the number of allowed variable names limited?
Are the names already known?
Then - a series of if sections
Otherwise - only your own module or perl / lua

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question