I have an array
$assid=Array
(
    [0] => Array
        (
            [0] => 6
            [1] => 2
            [2] => 3
        )
    [1] => Array
        (
            [0] => 4
            [1] => 5
            [2] => 6
        )
    [2] => Array
        (
            [0] => 6
        )
    [3] => Array
        (
            [0] => 2
            [1] => 3
        )
)
and
$key1=Array
    (
        [0] => 0
        [1] => 1
        [2] => 2
        [3] => 3
    )
Here $key1 means index of $assid
And a foreach loop
 @foreach($roles as $id=>$name)
<option value="{{$id}}"@if(in_array($id, $assid))selected="selected"@endif>{{$name}}</option>
   @endforeach
Here roles have 12 values.so array will iterate 12 times.my problem is that I want to append $assid[0],[1],[2],[3] so i $key1 values with foreach so I tried
$a=0;
     @foreach($roles as $id=>$name)
    <option value="{{$id}}"@if(in_array($id, $assid[$a]))selected="selected"@endif>{{$name}}</option>
    <?php  $a++;?>
       @endforeach
Because $key1 array as only index 0 1 2 3.so i need $a should be incremented as 0 to 3 inside foreach loop 12 iterations are there so after 3 it shows undefined index 4.i didn't get a proper solution. please help me.Please
 
     
     
     
    