jeudi 5 juillet 2018

foreach in foreach laravel

I pass two array from controller to view and then i want option to select when the value is the same. But i want to show all data from $arr_1 in select. and my result i get duplicate data in my select.

 $arr_1=["1","2","3","4"];
    $arr_2=["1","2","4"];
    @foreach($arr_1 as $val)
       @foreach($arr_2 as $value)
          @if($val==$value)
             <option selected></option>
          @else
             <option></option>
          @endif
       @endforeach
    @endforeach

Any solution for these?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire