in_arrayChecks if a value exists in an array
&reftitle.description;
boolin_arraymixedneedlearrayhaystackboolstrict&false;
Searches for needle in haystack using loose comparison
unless strict is set.
&reftitle.parameters;
needle
The searched value.
If needle is a string, the comparison is done
in a case-sensitive manner.
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.
&reftitle.returnvalues;
Returns &true; if needle is found in the array,
&false; otherwise.
&reftitle.examples;
in_array example
]]>
The second condition fails because in_array
is case-sensitive, so the program above will display:
in_array with strict example
]]>
&example.outputs;
in_array with an array as needle
]]>
&example.outputs;
&reftitle.seealso;
array_searchissetarray_key_exists