With the help of the wonderful Penagate, I was able to solve a problem I had when dealing with improper ampersands on certain websites.

The problem was that some sites doesn't escape their ampersands (&) with &. Here is a small line of code that will replace all & with & without messing up other html-encoded entities such as < etc.

PHP Code:
$body preg_replace('/&(?![#]?[a-z0-9]+;)/i'"&$1"$body);