arrayContains

arrayContains ( list/map array , object search , boolean[default:true] _byValue ) : boolean

Check if "search" is in "array". The methods is more flexible than .contains().

Example



if(arrayContains(global, "id_product", false)) // si la variable gloabl id_product n'existe pas
{
id_product = 500
}


tab = [1,4,6,9,10]
console(arrayContains(tab, 4)) // -> true
console(arrayContains(tab, "4")) // -> true
console(arrayContains(tab, 2)) // -> false
console(arrayContains(tab, "2")) // -> false

Parameters

array

The array to search in

search

The string to search for

_byValue (optional)

If true, we search the argument "search" in values of the list "array" only. If false (and if it is an associative array), "search" is searched in keys of "array" only.