- mb_convert_encoding: documentation ( source)
- utf8_decode: documentation ( source)
- mb_detect_encoding: documentation ( source)
- mb_strtolower: documentation ( source)
<?php
$value = utf8_decode('Österreich');
$encoding = mb_detect_encoding($value);
$country = $value;
if ($encoding != 'ISO-8859-1') {
$country = mb_convert_encoding($country, 'ISO-8859-1', $encoding);
}
$country = mb_strtolower($country, 'ISO-8859-1');
switch ($country) {
case 'deutschland':
case 'de':
echo "de";
break;
case 'österreich':
case 'at':
case 'oesterreich':
echo "at";
break;
default:
throw new Exception('Invalid country: ' . $value);
break;
}