Twig keys filter

 The keys filter returns the keys of an array. It is useful when you want to iterate over the keys of an array.

{% set sizes = [34, 36, 38, 40, 42] %}

{% for key in sizes|keys %}

    {{ key }}

{% endfor %}


Output

0

1

2

3

4


1 comment:

APTRON said...
This comment has been removed by a blog administrator.

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...