Comparisons\isEqualIn()

predicate returns Closure returns bool pure
T[] → (mixed → bool)
At a glance — Bind a set once; the returned Closure asks "is this value in the set?". Equivalent to a curried in_array().

Creates a predicate Closure that is true when the passed value is loosely equal to any element of a bound set.

/**
  * @param mixed[] $a
  * @return Closure(mixed):?bool
  */
Comparisons\isEqualIn(array $a): Closure

Returned Closure

When Comparisons\isEqualIn() is called, it returns the following Closure which can be used like a regular function.

/**
  * @param mixed $b
  * @return bool|null
  */
$function ($b)

Examples

Partial Application

This can be used to create a simple closure which can be used as a regular function.

$isColour = Comparisons\isEqualIn(['red', 'green', 'blue']);

var_dump($isColour('red'));    // true
var_dump($isColour('yellow')); // false

$colours = array_filter(['red', 'yellow', 'blue', 'pink'], $isColour);
print_r($colours); // ['red', 'blue']

Details

Comparisons Functions

Releated Equality Functions