This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Ilesyt
Hi, I am new to twig, and I learnt PHP 5 years ago but didn't use it, so it is VERY rusty. Ever since I discovered twig, I fell in love with it. Now I find myself replacing php whenever I can with twig.
For example, we have an array, that array is pulled from the database, the array has several values. We want to check if there is a value that exists in that array. If true, we show something in our template, if not, we skip it.
Now, would it be better to use twig and put a for loop, or use php to create a function?
Ilesyt
floriskoch said:
You can do this in twig:
{% if myVar in myArray %} // code {% endif %}
See:
Interesting, thank you.
1-3 of 3