PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

in_array

Tags: PHP 5.x PHP 7.x PHP 8.x

in_array — Checks if a value exists in an array.

Description

in_array(
    mixed $needle,
array $haystack,
bool $strict = false
): bool
Searches for needle in haystack using loose comparison unless strict is set.

Parameters

needle
The searched value.
haystack
The array.
strict
If the third parameter strict is set to true then the in_array() function will also check the types of the needle in the haystack.

Return Values

Returns true if needle is found in the array, false otherwise.