I need to check if the data array has a specific key, I tried it like this:
@if ( ! empty($data['currentOffset']) )
    <p>Current Offset: {{ $currentOffset }} </p>
@else
    <p>The key `currentOffset` is not in the data array</p>
@endif
But I always get <p>The keycurrentOffsetis not in the data array</p>.
You can use @isset:
@isset($data['currentOffset'])
    {{-- currentOffset exists --}}
@endisset
                        Use following:
@if (array_key_exists('currentOffset', $data))
    <p>Current Offset: {{ $data['currentOffset'] }} </p>
@else
    <p>The key `currentOffset` is not in the data array</p>
@endif
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With