- array_fill_keys: documentation ( source)
- range: documentation ( source)
- ord: documentation ( source)
<?php
$o = "";
$escape_char = $allowed_chars = array_fill_keys(range(0x32,0x255), "a");
$string = "hzgtfrzutrdetzttedcuztivcretfuzrtzt";
for ($i = 0; $i < strlen($string); $i++) {
$ch = $string[$i];
if (isset($allowed_chars[ord($ch)])) {
$o.=$allowed_chars[ord($ch)];
} else if (ord($ch) == 27) {
$i++;
$ch = $string[$i];
if (isset($escape_char[ord($ch)])) {
$o.=$escape_char[ord($ch)];
}
}
}
echo $o;