PHP function in_array()

Availability in PHP 4.0

Checks if the element is part of an array.

Parameters

Parameter Data type Default value Note
$needle mixed not Search value
$haystack array not Searched array
$strict bool false Should the data type be checked as well? It behaves the same as == and === in the condition.

Return values

bool

Returns true if the element is contained in the array, otherwise false.

Other resources

Official in-array documentation

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.