php 将富文本编辑后的内容取出

背景:项目中用了富文本编辑器,讲写完的内容存入了数据库,可是取出的时候由于有些展现地方并不须要样式,只想获取到内容,因此须要将带了html编码的信息解析出来。php

原始信息以下html

[task_desc] => <h1 class="mb-5" accuse="qtitle" style="margin: 0px 0px 5px; padding: 0px; word-break: break-all; 
"><span class="ask-title" style="display: inline-block; width: 595px; overflow: hidden; 
"><span style="font-family:Microsoft YaHei, SimHei, arial;font-size:16px;color:#333333;
"><span style="line-height: 26px;"></span></span></span><h1 class="mb-5" 
accuse="qtitle" style="margin: 0px 0px 5px; padding: 0px; word-break: break-all; 
"><span class="ask-title" style="display: inline-block; width: 595px; overflow: hidden; 
"><span style="font-family: 'Microsoft YaHei', SimHei, arial; color: rgb(51, 51, 51); 
"><span style="line-height: 26px; "><span style="font-size:16px;
">详细解说基因组学和医学的关系,以及基因组基因功能分类与疾病关系探索。
</span></span></span></span></h1></h1>数据库


1.获取的时候经过php的htmlspecialchars_decode()函数将信息里的 <内容转换成html的标记,再经过strip_tags()将html标记去除就能够获取到干净的内容了。编辑器

task_arr[$k]['task_desc'] = strip_tags(htmlspecialchars_decode($v['task_desc']));