title: how to Pass array from view to controller in Laravel?
body: <p>I make a form in blade.php, Here I can select multiple checkbox, and I want to pass selected input’s value to controller in a array.But I failed, I can not send the data.
  Here is code from view. The selected input’s value can be 1,2 etc;</p>
  
  <pre><code>&lt;form method="post" action="{{action('votesubmitController@votesubmit')}}" class="form"&gt;
  
  &lt;input type="hidden"  name="_token" value="{{ csrf_token() }}"&gt;
  
  @foreach($candidate_list[$post_list-&gt;id] as $candidate_list[$post_list-&gt;id])
  
  &lt;li&gt;
    &lt;input type="checkbox"  name= "selected[]"  value= {{ 
  $candidate_list[$post_list-&gt;id]-&gt;id }}&gt;
    &lt;label&gt;
    &lt;!-- some code here --&gt;
    &lt;/label&gt;
  &lt;/li&gt;
  
  @endforeach
  &lt;button type="submit" id="login-button"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is route-</p>
  
  <pre><code>Route::post('/votesubmit','votesubmitController@votesubmit');
  </code></pre>
  
  <p>If I write return $input in controller I find –</p>
  
  <pre><code>{"_token":"TQIUxVz0LjzM84Z7TaUPk3Y7BLZPjmXUyhXhlQfp","selected":
    ["1","2"]}
  </code></pre>
  
  <p>That’s I need. I do not know how to get selected value. When I get specific route error exception happens . and says "Undefined variable: selected".
  Here is my Controller’s code-</p>
  
  <pre><code>class votesubmitController extends Controller
  {
  public function votesubmit()
  {
    $input = Input::all();
   // return $input;     
    foreach ($selected as $selected) {
       echo $selected;
    }
  }
  }
  </code></pre>