Home > AI > Language > PHP >

in_array

in_array ( mixed $needle , array $haystack , bool $strict = false ) : bool

Searches for needle in haystack using loose comparison unless strict is set.

Example

<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
    echo "Got Irix";
}
if (in_array("mac", $os)) {
    echo "Got mac";
}
?>

Leave a Reply