将 HTML 代码转换为人类可理解的代码
Converting HTML Code to human understandable code
我在数据库中的大部分内容都是这样记录的。这如何翻译成HTML代码结构?
<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>
转换为:
<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>
您可以使用 html_entity_decode()
:
$str = '<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>';
echo html_entity_decode($str);
输出:
<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>
我在数据库中的大部分内容都是这样记录的。这如何翻译成HTML代码结构?
<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>
转换为:
<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>
您可以使用 html_entity_decode()
:
$str = '<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>';
echo html_entity_decode($str);
输出:
<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>