Determining Whether an Element Is in an Array
<?php
$countries = array('Germany' => 'German', 'France' => 'French', 'Spain' => 'Spanish');
$language = 'Spanish';
printf("<p>%s of our visitors speak %s.</p>\n", in_array($language, $countries) ? 'Some' : 'None', $language);
$language = 'asdfasd';
printf("<p>%s of our visitors speak %s.</p>\n", in_array($language, $countries) ? 'Some' : 'None', $language);
?>
Related examples in the same category