In an attempt to generate an RSS feed file, you have employed the strip_tags function to eliminate HTML tags from your application. However, you have encountered a shortcoming: strip_tags fails to remove HTML special code characters such as " ", "&", and "©".
To address this issue, consider utilizing alternative functions such as html_entity_decode, which decodes these special characters. Additionally, you can employ regular expressions through preg_replace:
$Content = preg_replace("/&#?[a-z0-9] ;/i","",$Content);
This expression targets the HTML character codes by matching strings that match the "©" format. By replacing these matches with an empty string, you effectively remove the special characters from your content.
Alternatively, to enhance precision, you can specify a stricter character limit for the replacement:
$Content = preg_replace("/&#?[a-z0-9]{2,8};/i","",$Content);
This modification limits the character range for matching, reducing the likelihood of accidentally replacing text that contains the "&" character alone.
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