How to convert special HTML entities back to characters in PHP

How to convert special HTML entities back to characters in PHP

In this post we will give you information about How to convert special HTML entities back to characters in PHP. Hear we will give you detail about How to convert special HTML entities back to characters in PHPAnd how to use it also give you demo for it if it is necessary.

Use the PHP htmlspecialchars_decode() function

You can use the PHP htmlspecialchars_decode() function to convert the special HTML entities such as &amp;&lt;&gt; etc. back to the normal characters (i.e. &<>).

The htmlspecialchars_decode() function is opposite of the htmlspecialchars() function which converts special HTML characters into HTML entities. Let’s check out an example:

<?php
$my_str = "I&#039;ll come &amp; &lt;b&gt;&quot;get you&quot;&lt;/b&gt;.";
 
// Decode &amp;, &lt;, &gt; and &quot;
echo htmlspecialchars_decode($my_str);
 
// Decode &amp;, &lt;, &gt;, &quot; and &#039;
echo htmlspecialchars_decode($my_str, ENT_QUOTES);
 
// Decode &amp;, &lt; and &gt;
echo htmlspecialchars_decode($my_str, ENT_NOQUOTES);
?>

i hope you like this one.

Hope this code and post will helped you for implement How to convert special HTML entities back to characters in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US