How to remove duplicated items in array on Twig

后端 未结 7 1058
-上瘾入骨i
-上瘾入骨i 2020-12-14 06:40

How to remove duplicated items in array on Twig?

I have array value in twig such as.

{{ set array = [\"testA         


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 07:45

    For symfony !

    Service : app/config/service.yml

    twig_array_unique_function:
        class: AppBundle\Twig\ArrayUniqueFunction
        tags:
            - { name: twig.function }
    

    Class : src/AppBundle/Twig/ArrayUniqueFunction.php

    Thk : https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Twig/TwigExtension.php

提交回复
热议问题