- var_dump: documentation ( source)
- bin2hex: documentation ( source)
- ctype_graph: documentation ( source)
- str_split: documentation ( source)
<?php
$string = '';
foreach(str_split(iconv("UTF-8", "Windows-1252", "my utf8 string áéíóú")) as $n => $c) {
if (! ctype_graph($c)) {
$c = '%'.bin2hex($c);
}
$string .= $c;
}
var_dump($string);