How to remove duplicated items in array on Twig?
I have array value in twig such as.
{{ set array = [\"testA
Twig is a VIEW engine, and should not be used - in theory - to manipulate data. It's a (very) good practice to use (assumingly) PHP to gather data, do all necessary manipulations and then pass the right data to your view.
That said, here's how you can do it in pure Twig syntax:
{% set newArray = [] %}
{% for name in array %}
{% if name not in newArray %}
My name is {{name}}
{% set newArray = newArray|merge([name]) %}
{% endif %}
{% endfor %}