【发布时间】:2015-12-09 09:56:08
【问题描述】:
如何检查是否向数组提供了任何值。在 PHP 中,我像这样添加到数组中:
$myArray['index1'] = $someVal1;
$myArray['index2'] = $someVal2;
问题是,当我在 Twig 中使用 |length 过滤器时,它会在 $someVal1 或 $someVal2 没有值时给出结果(这些值取自表单,因此不必填写)。所以我想检查整个数组中是否没有提供值,所以:
{% if myArray|what_filter_here? == 0|empty|whatever %} This text should not appear {% endif %}
可以在一个条件下完成吗?
【问题讨论】: