Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Get property of an object, stored in array

What is the right way to get property of an object, that is stored in array? I've tried that syntax:

{{ array['object'].property }}

but it's generating wrong php:

<?php echo ($array['object'])->property; ?>


85.3k
Accepted
answer

I can't understand why PHP can't execute <?php echo ($array['object'])->property; ?>

It seems you have to assign the array to a variable and get the property then:

{% set y = array['object']; %}
{{ y.x }}


11.9k

@phalcon yeah, I used that trick, but just thought that there's some more 'native' way of achieving that