0

I have following array:

array:3 [▼
  0 => "1234"
  1 => "1234"
  2 => "1234"
]

In twig I want to check if all element are same return true else return false.

  • 2
    Do it before passing data to twig. And just send some flag to twig. – u_mulder Sep 20 '22 at 13:48
  • 1
    While twig *can* do this natively it would be pretty clunky. If you 100% need to do it inside of a template then you should write your own custom twig function, there are some basics of doing that here: https://stackoverflow.com/questions/20662169/how-to-create-a-custom-twig-function-class-without-using-a-static-method – TheGentleman Sep 20 '22 at 13:50

0 Answers0