- preg_replace: documentation ( source)
<?php
$input = '=?UTF-8?Q?=c3=b8en?=';
echo "$input\n";
$output = '';
foreach(imap_mime_header_decode($input) as $element){
if($element->charset == 'utf-8'){
echo "utf8 = $element->text\n";
$output .= $element->text;
}
else{
echo "default = $element->text\n";
$output .= $element->text;
}
}
$string = preg_replace('/[^a-zæøåA-ZÆØÅ0-9 \-\.,:]/', '', $output);
echo "$string\n";
echo strlen($string);