Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting HTML Code to human understandable code

Most of my content in the database is recorded in this way. How can this be translated into HTML code structure?

<div class="main_title mb-4">n				<h2>New Arrival</h2>n				<span>Products</span>n				<p>Cum doctus civibus efficiantur in imperdiet deterruisset.</p>n			</div>n			<div class="isotope_filter">n				<ul><li><a href="http://www.example.com/index-2.html#0" id="all" data-filter="*">All</a></li><li><a href="http://www.example.com/index.html#0" id="popular" data-filter=".popular">Popular</a></li><li><a href="http://www.example.com/index-2.html#0" id="sale" data-filter=".sale">Sale</a></li></ul>n			</div>

Convert to:

<div class="main_title mb-4">n <h2>New Arrival</h2>n <span>Products</span>n <p>Cum doctus civibus efficiantur in imperdiet deterruisset.</p>n </div>n <div class="isotope_filter">n <ul><li><a href="http://www.example.com/index-2.html#0" id="all" data-filter="*">All</a></li><li><a href="http://www.example.com/index.html#0" id="popular" data-filter=".popular">Popular</a></li><li><a href="http://www.example.com/index-2.html#0" id="sale" data-filter=".sale">Sale</a></li></ul>n </div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could use html_entity_decode():

$str = '&#x3C;div class=&#x22;main_title mb-4&#x22;&#x3E;n&#x9;&#x9;&#x9;&#x9;&#x3C;h2&#x3E;New Arrival&#x3C;/h2&#x3E;n&#x9;&#x9;&#x9;&#x9;&#x3C;span&#x3E;Products&#x3C;/span&#x3E;n&#x9;&#x9;&#x9;&#x9;&#x3C;p&#x3E;Cum doctus civibus efficiantur in imperdiet deterruisset.&#x3C;/p&#x3E;n&#x9;&#x9;&#x9;&#x3C;/div&#x3E;n&#x9;&#x9;&#x9;&#x3C;div class=&#x22;isotope_filter&#x22;&#x3E;n&#x9;&#x9;&#x9;&#x9;&#x3C;ul&#x3E;&#x3C;li&#x3E;&#x3C;a href=&#x22;http://www.example.com/index-2.html#0&#x22; id=&#x22;all&#x22; data-filter=&#x22;*&#x22;&#x3E;All&#x3C;/a&#x3E;&#x3C;/li&#x3E;&#x3C;li&#x3E;&#x3C;a href=&#x22;http://www.example.com/index.html#0&#x22; id=&#x22;popular&#x22; data-filter=&#x22;.popular&#x22;&#x3E;Popular&#x3C;/a&#x3E;&#x3C;/li&#x3E;&#x3C;li&#x3E;&#x3C;a href=&#x22;http://www.example.com/index-2.html#0&#x22; id=&#x22;sale&#x22; data-filter=&#x22;.sale&#x22;&#x3E;Sale&#x3C;/a&#x3E;&#x3C;/li&#x3E;&#x3C;/ul&#x3E;n&#x9;&#x9;&#x9;&#x3C;/div&#x3E;';

echo html_entity_decode($str);

output:

<div class="main_title mb-4">n              <h2>New Arrival</h2>n               <span>Products</span>n              <p>Cum doctus civibus efficiantur in imperdiet deterruisset.</p>n           </div>n         <div class="isotope_filter">n               <ul><li><a href="http://www.example.com/index-2.html#0" id="all" data-filter="*">All</a></li><li><a href="http://www.example.com/index.html#0" id="popular" data-filter=".popular">Popular</a></li><li><a href="http://www.example.com/index-2.html#0" id="sale" data-filter=".sale">Sale</a></li></ul>n            </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading