PHPArrayin_array

Checks if a value exists in an array.

Syntax

in_array(mixed $needle, array $haystack): bool

Example

Enter values below to update the example in real time.

fruits
var_dump
in_array
$fruits = ["apple", "banana", "cherry"];
var_dump(in_array("banana", $fruits)); // bool(true)