We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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; ?>


98.9k
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 }}


19.2k

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