Twig 细枝-如果数组中有一个数组值

Twig 细枝-如果数组中有一个数组值,twig,Twig,我试着做这样的事,有人知道怎么处理吗 这就是我目前拥有的: {{ ('1' in app.request.pathInfo or '2' in app.request.pathInfo or '3' in app.request.pathInfo) ? 'active' : '' }} X 这就是我想要的: {{ (['1','2','3'] in app.request.pathInfo) ? 'active' : '' }} V 您可以尝试以下方法: array_intersect(['

我试着做这样的事,有人知道怎么处理吗

这就是我目前拥有的:

{{ ('1' in app.request.pathInfo or '2' in app.request.pathInfo or '3' in app.request.pathInfo) ? 'active' : '' }} X
这就是我想要的:

{{ (['1','2','3'] in app.request.pathInfo) ? 'active' : '' }} V
您可以尝试以下方法:

array_intersect(['1','2','3'], app.request.pathInfo);
逆逻辑工作;)


请参阅和/或
array\u intersect
不是默认的内置细枝如果这是解决方案,则问题标题与解决方案不匹配
{{ app.request.pathInfo in ['frame_brand', 'frame_elevation', 'frame_model'] ? 'active' }}