Reputation: 672
In my blade I am echoing a shipping ID. If I use "dd()" it dumps the number correctly. When I try to echo it I get error: "Undefined index: Id" I am puzzled why an error would throw if dd() works.
dd($shipping['Id']);
Outputs: 1234
echo $shipping['Id'];
Outputs: Error: Undefined index: Id
Upvotes: 0
Views: 1316
Reputation: 8618
You are using you code in foreach
. When dd($shipping['Id']);
that is first loop and first $shipping
contains 'Id'
, When using echo $shipping['Id'] you get error because one of $shipping
does not contain id
. For fix it use in blade use
@if(!empty($shipping['Id']))
{{$shipping['Id']}}
@endif
or
echo $shipping['Id'] ?? '';
Upvotes: 1