0

I have an array that I return from my controller to my view.
If I enter the following:

{{ $subpage["name"] }}

Laravel throws an error (undefinded index: name).
However, when I use:

{{ $subpage }}

I get this result:

[{"id":1,"name":"Additional Information","category":"General","link":"additionalinfo","created_at":"-0001-11-30 00:00:00","updated_at":"-0001-11-30 00:00:00"}]

So I really don't see what I'm doing wrong?

Framework: Laravel 5

1 Answer 1

2

You have an object, in an array, you can notice that since you have curly braces ({}) around your variables.

You will need to use $subpage[0]->name to access the value just like you would in a controller, to access some model's object.

Sign up to request clarification or add additional context in comments.

1 Comment

that did the trick!, Thanks ... I already upvoted the answer, I'll mark it as the correct one as soon as possible ...

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.