|
PHP: check array contains a valueUse PHP's <?php
$myArray = array('guitar', 'piano', 'saxophone', 'trumpet', 'violin');
if (in_array('trumpet', $myArray)) {
echo "Array contains 'trumpet'" . PHP_EOL; // will be printed
}
if (in_array('banjo', $myArray)) {
echo "Array contains 'banjo'" . PHP_EOL; // will not be printed
}
|