0

I'm trying to output the names out of an array

when I output them as a {!! !!} i get the following error "Array to string conversion in .." but with a @dump i get the following data:

array(2){[0]=> object(stdClass)#7052(1){["data"] => string(5)"data1"} [1]=> object(stdClass)#7049(1){["data"] =>string(5)"data2"}}

I've already tried:

@foreach($items as $item)
{!! $item !!}
@endforeach

but this did not solve the ploblem

I'm using php blade to solve this problem

1
  • try $item['data'] Commented Oct 26, 2021 at 5:23

2 Answers 2

2

The quickest way to view an array in string format is to do this

{!! json_encode($item) !!}

Then more likely your final answer will be something like this.

{!! $item['my_key_name'] !!}
Sign up to request clarification or add additional context in comments.

Comments

0

Your array is items[0] = data['data1','data2'] so when you use foreach($items as $item), $item returns value data so you need 2nd loop to extract the data or you need to use

@foreach($items[0] as $item)
{!! $item !!}
@endforeach

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.