Reputation: 963
I recently asked a question about how I could convert the following to Twig
$firstDate = array_pop(array_keys($dates));
After being suggested to use the slice filter, I worked on it for a while and came up with something that appears to do the job
{% set firstDate = (dates|keys)|last %}
Now I have another problem. I essentially have to do the following in Twig
foreach (array_keys($dates[$firstDate]) as $classLetter) {
I have made a horrible effort to do this, but it doesnt seem to like the []
{% for dates[firstDate]|keys in classLetter %}
Is there anyway I can do something like the above PHP code?
Thanks
Upvotes: 1
Views: 315
Reputation: 963
After spending a while on it, came up with a solution
{% for classLetter in attribute(dates, firstDate)|keys %}
Upvotes: 1