twig for
snippet in php

twig loop variables

user6492

{% for user in users %}
    {{ loop.index }} - {{ user.username }}
{% endfor %}

twig for

user5792

<ul>
    {% for key, user in users %}
        <li>{{ key }}: {{ user.username|e }}</li>
    {% endfor %}
</ul>

how to for loop twig

user304

{% for i in 0..10 %}
    * {{ i }}
{% endfor %}

how to for loop twig

user3005

{% for letter in 'a'..'z' %}
    * {{ letter }}
{% endfor %}

modele de twig html : payant

user3451

<?php
// menu.php
// inclure  l'autoloader
include 'vendor/autoload.php';

try {
    // le dossier ou on trouve les templates
    $loader = new Twig\Loader\FilesystemLoader('templates');

    // initialiser l'environement Twig
    $twig = new Twig\Environment($loader);

    // load template
    $template = $twig->load('Menu.html');

    // set template variables
    // render template
    echo $template->render(array(
        'lundi' => 'Steak Frites',
        'mardi' => 'Raviolis',
        'mercredi' => 'Pot au Feu',
        'jeudi' => 'Couscous',
        'vendredi' => 'Poisson',
    ));

} catch (Exception $e) {
    die ('ERROR: ' . $e->getMessage());
}