I am receiving an undefined offset: 1 error exception for a for-each loop when the input for the scheduling tool I am trying to fix is empty. I'm newish to PHP/Laravel and have been assigned to fix someone else's code unfortunately.
I have researched other posts are have experimented with issets and array_key_exists if loops but may have been using them incorrectly? The error points to the first line of the foreach loop posted in the image. Thanks for the input
@foreach ($headliners[$location->id] as $h)
      @if  ($h['count'] > 2)
          <th colspan="{{ $h['count'] }}"> {{ $h['headliner'] }}</th>
      @else
          <th colspan="{{ $h['count'] }}" class="vertical"><p>{{ $h['headliner'] }} </p></th>
      @endif
@endforeach
