Convert all HTML entities to their applicable characters
Example 1
Running
1.html_entity_decode('Kevin & van Zonneveld');
Could return
1.'Kevin & van Zonneveld'
Example 2
Running
1.html_entity_decode('<');
Could return
1.'<'
function html_entity_decode( string, quote_style ) {
// Convert all HTML entities to their applicable characters
//
// version: 901.714
// discuss at: http://phpjs.org/functions/html_entity_decode
// + original by: john (http://www.jd-tech.net)
// + input by: ger
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// + improved by: marc andreu
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// - depends on: get_html_translation_table
// * example 1: html_entity_decode('Kevin & van Zonneveld');
// * returns 1: 'Kevin & van Zonneveld'
// * example 2: html_entity_decode('&lt;');
// * returns 2: '<'
var histogram = {}, symbol = '', tmp_str = '', entity = '';
tmp_str = string.toString();
if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
return false;
}
// & must be the last character when decoding!
delete(histogram['&']);
histogram['&'] = '&';
for (symbol in histogram) {
entity = histogram[symbol];
tmp_str = tmp_str.split(entity).join(symbol);
}
return tmp_str;
}