Skip to content

Instantly share code, notes, and snippets.

@jgdoncel
Created October 2, 2013 13:35
Show Gist options
  • Save jgdoncel/6793877 to your computer and use it in GitHub Desktop.
Save jgdoncel/6793877 to your computer and use it in GitHub Desktop.
Eliminar caracteres no UTF8 de una cadena
// Supposing your want to be sure that $string is composed by valid UTF-8 characters:
$string = iconv("UTF-8","UTF-8//IGNORE",$string);
// If you want to remove none ISO-8859-1 characters from this string:
$string = iconv("UTF-8","ISO-8859-1//IGNORE",$string);
$string = iconv("ISO-8859-1","UTF-8",$string);
// If you still have characters you want to be ignored, try this:
$string = recode_string("us..flat", $string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment