title: Workaround for 'max_input_vars' limit
body: <p>Currently I'm working on a large form with dynamic number of input fields, it can get extremely large (above 3k variables or more) and it causes problems with 'max_input_vars' option.
  I'm looking for a workaround for this issue (I'm not interested in increasing the value of 'max_input_vars' option), so currently I'm trying to join all form fields values into single field (using jQuery serialize() method) and then recreate the variables on the server side. 
  This is what I have so far:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Workaround for max_input_vars&lt;/title&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  if($_SERVER["REQUEST_METHOD"]==="POST" &amp;&amp; !empty($_POST["data"])) {
      $vars = explode("&amp;", $_POST["data"]);
      $data = array();
      foreach($vars as $var) {
          parse_str($var, $variable);
          assign_var($_POST, $variable);
      }
      echo "&lt;pre&gt;";
      var_dump($_POST);
      echo "&lt;/pre&gt;";
  }
  function assign_var(&amp;$target, $var) {
      $key = key($var);
      if(is_array($var[$key])) 
          assign_var($target[$key], $var[$key]);
      else {
          if($key==0)
              $target[] = $var[$key];
          else
              $target[$key] = $var[$key];
      }   
  }
  ?&gt;  
      &lt;form id="myForm" method="POST"&gt;
          &lt;input type="text" name="var_1" value="&lt;?php echo htmlentities("double quote: \"hello\"");?&gt;"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_2" value="&lt;?php echo htmlentities("single quote: 'hello'");?&gt;"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_3" value="&lt;?php echo htmlentities("text with &amp; ampersant");?&gt;"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_4" value="&lt;?php echo htmlentities("animals");?&gt;"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="1"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="2"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="3"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="4"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="5"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="6"/&gt;&lt;br/&gt;
          &lt;input type="text" name="matrix[]" value="7"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_5" value="abc"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_6" value="bcd"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_7" value="cde"/&gt;&lt;br/&gt;
          &lt;input type="text" name="var_8" value="def"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[colors][]" value="red"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[colors][]" value="blue"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[colors][]" value="green"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[weight][]" value="75"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[weight][]" value="83"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[weight][]" value="62"/&gt;&lt;br/&gt;
          &lt;input type="text" name="multi_matrix[height][]" value="170"/&gt;&lt;br/&gt;
          &lt;input type="submit" value="Send"&gt;
      &lt;/form&gt;
      &lt;style&gt;
      input {
          margin: 5px 0;
      }
      &lt;/style&gt;
      &lt;script type="text/javascript"&gt;
      (function(){
          $(function(){
              $("#myForm").submit(function(event) {
                  var $this = $(this);
                  var data = $this.serialize();
                  $this.find("input, textarea, select, button").remove();
                  $this.append("&lt;input type='hidden' class='data' name='data'/&gt;");
                  $this.find("input.data").val(data);
              });
          });
      })(jQuery);
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you can see, I'm intercepting the submit event and replace all form fields with single 'data' field. On PHP side I'm using explode() and pars_str() methods to recreate the variable, lastly I want to put the variable into $_POST array, so I created simple recursive function that can handle simple values and multidimensional associative arrays.
  The result is a $_POST array filled with form values, as if the form was submitted normally.</p>
  
  <p>What do you think about above method ? Maybe there's a much simpler solution to the problem that I hadn't noticed earlier ? If not, are there any options to improve the above code ? Are there any negative side effects of the above solution ?</p>
  
  <p>Thanks in advance !</p>