PUBLISHED : |in_any

**SPIP**

# Article validated

The article "**|in_any** (https://www.spip.net/en_article6564.html)" was
validated by <multi>[ar]جورج[fr]George [en]George</multi>.

* * *

## |in_any

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

**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
(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