in_array( ) function return true if an array contains a specific value
//bool in_array ( mixed needle, array haystack [, bool strict] )
<?
$needle = "Sam";
$haystack = array("Johnny", "Timmy", "Bobby", "Sam", "Tammy", "Joe");
if (in_array($needle, $haystack)) {
print "$needle is in the array!\n";
} else {
print "$needle is not in the array\n";
}
?>
Related examples in the same category