1

Result of a query stored in multi-dimension array, How to display these results in the view. The array example is as below.

Multi-dimension array

I am using laravel framework, using blade in view to display results.

I have tried foreach as below,

@foreach($adverts as $advert)
   @foreach($advert as $keyword)
     {{$keyword}}
  @endforeach
@endforeach

The above foreach didn't worked. I would like to access all the elements under "keywords" in my view.

Thanks for your answers in advance.

1 Answer 1

2

Try this:

@foreach($adverts as $advert)
   @foreach($advert->keywords as $keyword)
     {{$keyword}}
  @endforeach
@endforeach
Sign up to request clarification or add additional context in comments.

2 Comments

You are welcome. Good luck (please mark the answer as the right one ;) )
ismail I have noticed I am getting accumulative keywords from all element of array,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.