Ad

Converting HTML Code To Human Understandable Code

- 1 answer

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>
Ad

Answer

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>
Ad
source: stackoverflow.com
Ad