title: Laravel Pass Array Parameters to Filter
body: <p>I need to pass an array to a filter in my controller's constructor. The problem is that to pass parameters to a filter you do:</p>
  
  <pre><code>$this-&gt;beforeFilter('filterName:param1,param2');
  </code></pre>
  
  <p>And to pass an array, I need to <code>json_encode</code> which makes the array as a string separated by comma. So the following command:</p>
  
  <pre><code>$array = ['this', 'that', 'other'];
  $this-&gt;beforeFilter('filterName:' . json_encode($array));
  // The above line basically becomes:
  // $this-&gt;beforeFilter('filterName:["this","that","other"]');
  </code></pre>
  
  <p>is passed to my filter as:</p>
  
  <pre><code>Route::filter('filterName', function($route, $request, $param1, $param2, $param3)
  {
      // $param1 is ["this"
      // $param2 is "that"
      // $param3 is "other"]
  });
  </code></pre>
  
  <p>Since I don't know how big my array is, I can't reconstruct the array. What can I do?</p>
  
  <p><strong>Update</strong></p>
  
  <p>One thing I could so is</p>
  
  <pre><code>Route::filter('filterName', function($route, $request, $value)
  {
      $params = array_except(func_get_args(), array(0, 1));
      if(count($params) &gt; 3) {
          $params = json_decode(implode(",", $params));
  
          // Now use $params
      }
  });
  </code></pre>
  
  <p>This works fine for an array. but if I pass an embedded array, the result becomes an <code>stdObject</code>, which is okay but I don't like the fact that I passed an array, and got an object.</p>