|in_any

Usage : [(#BALISE|in_any{tab,def})]

The filter |in_any checks if a value exists in an array. So it works exactly like the php function in_array with 2 differences :

  • If the 1st argument tab passed to the |in_any filter is not an array, in_array} throws an error, whereas in_any does not: in this case, in_any tries to de-serialize this argument in order to treat it as an array if successful.
  • If there is a 2nd argument def to the filter, it is this value that is returned in case tab is not an array.

Example :

[in_array throws an error (#VAL{10}|in_array{patablo}) ] 
[in_any does not throw an error and returns: '(#VAL{10}|in_any{patablo,not an array})'] 
 
<!--Useful only when these are not constant values: -->
[(#GET{age}|in_any{#ENV{ages_possibles}}|yes) Welcome]

See also: the filter |find which has the same function, but with reversed arguments.

Author jack Published :

Translations : English, français, Nederlands