I have a string which contains characters of different encoding
I need to traverse it and to remove any character that is below 32 or above 127
I am trying the following code
Code: Select all
for ($i=0; $i<mb_strlen($file); $i++) {
$ch = $file[$i];
$value = ord($ch);
if ($value < 32 || $value > 127) {
$file = mb_substr($file, 0, $i) . mb_substr ($file, ($i+1));
}
}The problem could be either in line:
$ch = $file[$i];
or in line
$file = mb_substr($file, 0, $i) . mb_substr ($file, ($i+1));
here is an example:
$file ="×