title: i get data foreach and want set key input is $key.But i have a error.This is my code of me at blade laravel
body: <p>i get data foreach and want set key input is $key.But i have a error.This is my code of me at blade laravel.</p>
  <pre><code>    @foreach ($typeCost-&gt;typeCostCompany as $key =&gt; $item)
                                          &lt;tr&gt;
                                              &lt;td style=&quot;text-align: center; vertical-align: middle;&quot;&gt;{!! $key + 1 !!}&lt;/td&gt;
      
                                              &lt;td style=&quot;text-align: center; vertical-align: middle;width :200px&quot;&gt;
                                                  {{-- {!! Form::select('company_id[]', ['' =&gt; trans('system.dropdown_choice')] + $companies, old('company_id[]', $item-&gt;company_id), ['class' =&gt; 'form-control select2']) !!} --}}
                                                  {!! Form::select('company_id[$key][]', $companies, old('company_id[]', explode(' ', $item-&gt;company_id)), ['class' =&gt; 'form-control select2','multiple', 'required']) !!}
                                              &lt;/td&gt;
  @endforeach
  </code></pre>