$countries = array( 'USA' => 'English', 'Spain' => 'Spanish',
'France' => 'French', 'Argentina' => 'Spanish');
function array_get_keys($search, $array)
{
$keys = array();
foreach($array as $key => $value)
if($value == $search)
$keys[] = $key;
if(count($keys) == 0)
$keys = FALSE;
return $keys;
}
$language = 'Spanish';
$spoken = array_get_keys($language, $countries);
printf("Countries where %s is spoken: %s.
\n",
$language,
$spoken ? implode(', ', $spoken) : 'None');
$language = 'Tagalog';
$spoken = array_get_keys($language, $countries);
printf("Countries where %s is spoken: %s.
\n",
$language,
$spoken ? implode(', ', $spoken) : 'None');
?>