Skip to content

Instantly share code, notes, and snippets.

@lleitep3
Created March 17, 2012 16:09
Show Gist options
  • Save lleitep3/2061549 to your computer and use it in GitHub Desktop.
Save lleitep3/2061549 to your computer and use it in GitHub Desktop.
ascii2entities
<?php
// encontrada nesse link
// http://www.php.net/manual/en/function.htmlentities.php
function ascii2entities($string){
for($i=128;$i<=255;$i++){
$entity = htmlentities(chr($i), ENT_QUOTES, 'cp1252');
$temp = substr($entity, 0, 1);
$temp .= substr($entity, -1, 1);
if ($temp != '&;'){
$string = str_replace(chr($i), '', $string);
}
else{
$string = str_replace(chr($i), $entity, $string);
}
}
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment