[PHP] Preg_relpace ampersand ( & ) with &
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);
Re: [PHP] Preg_relpace ampersand ( & ) with &
In case the one provided here is insufficient, here is a far more complex expression to perform the same task:
http://regexadvice.com/blogs/mash/ar...01/26/323.aspx