1

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

1 Answer 1

1

After spending a while on it, came up with a solution

{% for classLetter in attribute(dates, firstDate)|keys %}
Sign up to request clarification or add additional context in comments.

Comments

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.