Answer the question
In order to leave comments, you need to log in
How to access the property of the last element of an array without a loop in smarty?
There is an array $item.messages, how to access the .uid property of the last element of the array without a loop? I tried these options, it doesn't work:
{if $item.messages[$item.messages|@end]['uid'] == $user.id}{/if}
{if $item.messages[$item.messages|@array_keys|@array_pop]["uid"] == $user.id}{/if}
Answer the question
In order to leave comments, you need to log in
Try using count and then minus one. And there will be the key of the last element.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question