How to remove html special chars

0 votes

I am creating a RSS feed file for my application in which I want to remove HTML tags, which is done by strip_tags. But strip_tags is not removing HTML special code chars:

  & © etc.

Any function which I can use to remove these special code chars from my string?

Nov 3, 2020 in PHP by kartik
• 37,520 points
317 views

1 answer to this question.

0 votes

Hello,

Either decode them using html_entity_decode or remove them using preg_replace:

$Content = preg_replace("/&#?[a-z0-9]+;/i","",$Content); 

Hope it helps!!

answered Nov 3, 2020 by Niroj
• 82,780 points

Related Questions In PHP

0 votes
1 answer

How to remove MySQL root password?

Hello @kartik, You need to set the password ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,780 points
3,625 views
0 votes
1 answer

How to make PDF file downloadable in HTML link?

Hello @kartik, Try this: <a href="./directory/yourfile.pdf" download="newfilename">Download the pdf</a> Where newfilename is ...READ MORE

answered Aug 27, 2020 in PHP by Niroj
• 82,780 points
6,521 views
0 votes
1 answer

How to remove duplicate values from an array in PHP?

Hello @kartik, Use array_unique(): Example: $array = array(1, 2, 2, 3); $array ...READ MORE

answered Sep 15, 2020 in PHP by Niroj
• 82,780 points
903 views
0 votes
1 answer

How to display HTML tags as plain text ?

Hello @kartik, Replace < with &lt; and& ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,780 points
972 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,780 points
8,613 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,780 points
963 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,780 points
778 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,780 points
9,382 views
0 votes
1 answer

How to remove all special characters from a string?

Hello @kartik, This should do what you're looking ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,780 points
4,326 views
0 votes
1 answer

How to prevent XSS with HTML/PHP?

Hello, HTML Encoding htmlspecialchars will convert any "HTML special characters" ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,780 points
333 views