title: Laravel 5 Undefined offset: 1
body: <p>In my laravel blade file, I have a multiselect box and the values are coming from the database / controller. Below are the values:</p>
  
  <blockquote>
    <p>[{"id":1,"name":"United States"},{"id":2,"name":"United
    Kingdom"},{"id":3,"name":"China"}]</p>
  </blockquote>
  
  <p>I wanted to show the values in the multiselect box as well as the already selected values by the user (that's are coming from the controller in another variable), see below;</p>
  
  <blockquote>
    <p>[{"id":2,"name":"United Kingdom"}]</p>
  </blockquote>
  
  <p>Below is the code for the multi select box:</p>
  
  <pre><code>&lt;select multiple="multiple" name="warehouseId[]" id="warehouse" class="form-control" style="width:100%;" required&gt;
      @if($warehouseData)
          @foreach ($warehouseData as $key =&gt; $warehouse)
              &lt;option value="{{$warehouse-&gt;id}}" @if($adminUserWarehouseSelectedData[$key]-&gt;name == $warehouse-&gt;name) Selected @endif&gt;{{$warehouse-&gt;name}}&lt;/option&gt;
          @endforeach
      @endif
  &lt;/select&gt;
  </code></pre>
  
  <p>But it ended up with an error - </p>
  
  <blockquote>
    <p>Undefined offset: 1</p>
  </blockquote>