

Twig counter PHP equivalent
source link: https://www.codesd.com/item/twig-counter-php-equivalent.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Twig counter PHP equivalent
Hello I would like do something like that with my Twig template
<?php
for( $i = 0; $i <= 5; $i++ ) {
// Not display the first number
if( $i <= 1 ) {
continue;
}
// Displaying numbers from 2 to 5
echo $i ,'<br/>';
}
?>
How can I do that ?
Thanks for your help.
From the documentation you can use this to iterate numbers
{% for i in 0..10 %}
* {{ i }}
{% endfor %}
Also from the documentation you can add conditions like this
<ul>
{% for user in users if user.active %}
<li>{{ user.username|e }}</li>
{% endfor %}
</ul>
So if you combine the two you end up with something like this.
{% for i in 0..5 if i<= 1 %}
* {{ i }}
{% endfor %}
Untested but should work. THe documentation : http://twig.sensiolabs.org/doc/tags/for.html
Related Articles
What is the PHP equivalent of MySQL UNHEX ()?
Netbeans syntax highlighting for volt (twig) and php in phtml files
The PHP equivalent of Java's Character.getNumericValue (char c)?
PHP Equivalent of Ruby's Rescue
Is there a PHP equivalent of Rails migrations?
Is there a PHP-equivalent function for the Python os.path.normpath () file?
Is there a PHP equivalent to Compass?
PHP equivalent password hash of following code .NET
What is the PHP equivalent of the VB class stream?
Is there anything in PHP equivalent to LINQ in C #?
PHP: equivalent to the MySQL function SUBSTRING_INDEX?
What is the PHP equivalent of Javascript undefined?
PHP equivalent to fb.getloginstatus
Cookies counter php
Recommend
-
85
“@JamesWidman @_photex_ @intel @nvidia @AMD Installing Linux is sort of the equivalent of moving to Canada when one doesn’t like US political trends. Nope, we’ve got to fight for the freedoms we have today, where we have them today.”
-
38
README.md
-
46
Affected versions Twig 1.0.0 to 1.37.1 and 2.0.0 to 2.6.2 are affected by this security issue. The issue has been fixed in Twig 1.38.0 and 2.7.0. This vulnerabili...
-
41
Daniel’s Dev BlogDaniel's Dev Blog Developer, Trainer, Open Source Contributor Blog About me
-
17
DRY Templating with Twig and Craft CMS Published on 31.05.2017, by Pierre StoffeAll of us at Base...
-
10
Twig iterate / read and get value - Octobercms advertisements Hi guys its rather a very basic question, had chance to look several questions o...
-
7
Oddict Twig Pro review: Lossless Bluetooth is here at last By Connor Nolan Published 2 days ago Your phone probably...
-
9
-
7
Twig acquire...
-
5
AI to answer complex technical questions from customersSort by: Thank you @hnshah for sharing Twig with the product hunt community. 👋🏼 Hey Product...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK