Skip to content

Instantly share code, notes, and snippets.

@Quinten
Created June 6, 2011 13:01
Show Gist options
  • Save Quinten/1010197 to your computer and use it in GitHub Desktop.
Save Quinten/1010197 to your computer and use it in GitHub Desktop.
aggressive formatting for xml in php. Seems to solve most of the encoding and html entity problems. experimental
function properXML($str){
//return iconv("UTF-8", "ISO-8859-1//TRANSLIT", preg_replace("/&/", "and", html_entity_decode(strip_tags($str), ENT_COMPAT, 'UTF-8')));
return utf8_encode(preg_replace("/&/", "and", html_entity_decode(strip_tags($str), ENT_COMPAT, 'UTF-8')));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment