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