function html_entitize($string) { $encoded = null; for ($i = 0, $j = strlen($string); $i < $j; $i += 1) { switch (rand(0,1)) { case 0: $encoded .= sprintf('&#%s;', ord($string[$i])); break; case 1: $encoded .= sprintf('&#x%s;', dechex(ord($string[$i]))); break; } } return $encoded; }