Turning HTML character entities to 'regular' letters... why is it only partially working?
- by Jack W-H
I'm using all of the below to take a field called 'code' from my database, get rid of all the HTML entities, and print it 'as usual' to the site:
<?php $code = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $code);
$code = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $code);
$code = html_entity_decode($code); ?>
However the exported code still looks like this:
progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’img/the_image.png’);
See what's going on there? How many other things can I run on the string to turn them into darn regular characters?!
Thanks!
Jack