in_array

Syntax: bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )
Description: Checks if a value exists in an array

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

OUTPUT

Got Irix
false
Got 1

 

Leave a Reply

Your email address will not be published. Required fields are marked *