Reputation: 2617
I seem to be hitting the limit on max_input_vars
in a PHP script I'm working on. I know I can just increase the limit (which I did while I'm refactoring the script) but I don't want that to be the end solution.
The way I believe max_input_vars
works is that each nested level of an array is allotted an amount of elements less than the value of max_input_vars
.
So a two-dimensional array such as $array1[999][999]
would be fine assuming the value of max_input_vars
is set to 1000.
However a two dimensional array such as $array2[1010][2]
would violate the value if it was set to 1000.
Is my understanding correct? If not, how does this setting really work?
Just to be complete, My POST string looks like this:
Note: I copied this right from my browser inspector under the "form data" section of the request. I took the URL encoded value and passed it through parse_str
to make it readable.
array(172) {
["line_1"]=>
string(11) "1_85021_1_2"
["line_2"]=>
string(11) "1_85038_1_2"
...
["line_167"]=>
string(11) "1_85077_1_2"
["QUANTITY"]=>
array(167) {
["1_85021_1_2"]=>
string(6) "118685"
["1_85038_1_2"]=>
string(6) "237520"
...
...
}
["DATE1"]=>
array(167) {
["1_85021_1_2"]=>
string(0) ""
["1_85038_1_2"]=>
string(0) ""
...
...
["SPLIT"]=>
array(167) {
["1_85021_1_2"]=>
string(1) "2"
["1_85038_1_2"]=>
string(1) "0"
...
...
}
["DATE2"]=>
array(166) {
["1_85021_1_2"]=>
string(0) ""
["1_85038_1_2"]=>
string(10) "08/08/2017"
...
...
}
["COMMENT"]=>
array(166) {
["1_85021_1_2"]=>
string(0) ""
["1_85038_1_2"]=>
string(6) "test21"
...
...
}
For verbosity, the exact error I'm getting is here:
PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
Upvotes: 2
Views: 2027
Reputation: 78994
Each array element is it's own variable sent as, for a single dimension:
array1%5B%5D=1 & array1%5B%5D=1
And for two dimensions:
array1%5B1%5D%5B0%5D=1 & array1%5B2%5D%5B0%5D=1
So array1[999][999]
WILL violate max_input_vars
if set at 1000, because array1[0][0]
thorough array1[0][999]
is 1000 variables. In this case, adding array1[1][0]
will put it over 1000 and generate:
Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
Upvotes: 3