I want to get an array with only the first character from an existing array. This is my code:
$tag_array = array('ächzen', 'ßüß', 'test');
function firstCharArray($array){
$result = array();
foreach($array as $item){
$result[] = $item[0];
}
return $result;
}
$characters = firstCharArray($tag_array);
echo '<pre>';
print_r($characters);
echo '</pre>';
The problem is that I get � for umlauts. The script is encoded in UTF-8 without BOM. I don't know what I'm doing wrong. I also tried to set the locale but it doesn't helped so far.