foreach access empty value from input field

  foreach, laravel, loops, php
<input class="select2" name="{{$section['id']}}[]" data-placeholder="Select a State" style="width: 100%;">
foreach ($data["{$section['id']}"] as $value) { 
    if (!empty($value)) {     
        code......

    }
}

there is 8 input field with the same name attribute but if I fill only 3 fields then (Undefined offset: 4) this error shows I know that foreach access 4 field value but it is empty how to solve this problenm

Source: Ask PHP

LEAVE A COMMENT