How can I check if any values are provided to the array. In PHP I'm adding to the array like this:
$myArray['index1'] = $someVal1;
$myArray['index2'] = $someVal2;
The problem is that when in Twig I use |length filter it gives results when $someVal1 or $someVal2 have no values (these are values taken from the form so they don't have to be filled). So I want to check if the values are not provided in the whole array, so:
{% if myArray|what_filter_here? == 0|empty|whatever %} This text should not appear {% endif %}
Can it be done in one single condition?
Something like:
{% if myArray|length > 0 %}
This text should not appear
{% endif %}
Try with empty
-
{% if myArray is empty %} ... {% endif %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With