← All built-ins / in_array()

in_array()

in_array(...$args): bool

Parameters

NameTypeDescription
$needlemixedvalue to find
$haystackarrayarray to search

Return value

true when the value occurs in the array.

Example

var_dump(in_array(2, [1, 2, 3]));
var_dump(in_array("x", ["a", "b"]));
bool(true)
bool(false)

See also

array_search()array_key_exists()