Remove non-utf8 characters from string
Function to remove any bad formatted bytes.
function remove_bs2($string) {
$str_array = str_split($string);
$new_str = '';
foreach ($str_array as $char) {
$char_no = ord($char);
if ($char_no == 163) {
$new_str .= $char;
continue;
} // keep £
if ($char_no > 31 && $char_no < 127) {
$new_str .= $char;
}
}
return $new_str;
}