Submitted : |in_any

**SPIP**

# Article submitted

The article "**|in_any**
(https://www.spip.net/ecrire/?exec=article&id_article=6564)" is submitted
for publication. on Friday 22 May 2020.

* * *

## |in_any

Friday 22 May 2020 , by [jack](.././?page=auteur&id_auteur=593&)

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

The filter **|in_any** is used to test the presence of the value in a
values table. 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**} causes an error, whereas **in_any** does not: in this
case, **in_any** tries to deserialize 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 the case where `tab` is not an array.

**Example :**

    [
    
    in_array causes an error
    
    (

    #VAL

    {10}

    |in_array

    {patablo}

    )

    ]

    [
    
    in_any does not cause 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
(https://www.spip.net/ecrire/?exec=article&id_article=4997)** which has the
same function, but with reversed arguments.

— Sent by SPIP (https://www.spip.net/)

rubon199.jpg