Stripping Out Obstinate HTML Special Characters
The strip_tags function, though adept at removing HTML tags, fails to tackle pesky HTML special characters such as for non-breaking space or © for the copyright symbol. This can be a stumbling block in creating clean RSS feeds.
To remedy this issue, consider utilizing one of the following strategies:
$Content = preg_replace("/&#?[a-z0-9]{2,8};/i","",$Content);
Note that the above pattern includes a modification suggested by Jacco to prevent unintended replacements of genuine ampersand characters (&) in unencoded text. By specifying a character range of {2,8}, the pattern is more discriminative in targeting HTML special codes.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3