Dit artikel is niet beschikbaar in het Dutch, weergeven in het English
contains
TABLE OF CONTENTS
Check if a string or array contains a value
Definition
boolean contains(array|string $source, any $value)
For array $source, returns whether the array contains an element equal to $value.
For string $source, returns whether $value is a substring of $source.
Parameters
array | string $source
An array or a string to be searched.
any $value
Value to look for in $source.
Returns
boolean
true if $source contains $value, otherwise false.
Examples
Transformation
{
a: contains('ace0', 'a'),
b: contains('ace0', 'b'),
c: contains('ace0', 'ce0'),
d: contains('ace0',`0`),
e: contains('ace0', ''),
f: contains(['a', 'c',`true`,`null`],`true`),
g: contains(['a', 'c',`true`,`null`],`null`),
h: contains(['a', 'c',`true`,`null`],`[]`),
i: contains(['a', 'c',`true`,`null`],`{}`)
}Result
{
"a": true,
"b": false,
"c": true,
"d": true,
"e": true,
"f": true,
"g": true,
"h": false,
"i": false
}Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article