PHP » Arrays » in_array()

Syntax:
bool in_array(mixed value, array array)
value
The value to look for.
array
The array to look in.

Returns whether a value exists in an array.

This function returns TRUE if a specific value exists in an array.

Examples

Code:
<?php

$char = 'å';
if (in_array($char, range('a', 'z'))) {
   print "$char is in the English alphabet";
} else {
   print "$char is not in the English alphabet";
}

?>
Output:
å is not in the English alphabet
Explanation:

The code uses the range() and in_array() functions to check whether the character $char is a letter in the English alphabet.

See Also: