php正则匹配将section替换成div标签

php正则匹配将section替换成div标签。
如题,我用的是百度编辑器,但是要适应小程序。小程序有些标签不支持,我现在要将文库中的section标签替换成div,请问,应该怎么做?能不能写个替换的例子看看,谢谢啦

按照你的要求编写的把section标签替换成div标签的例子程序如下
<?php
$str='<section style="font-size:16px;"><section class="_135editor"><p><strong class="135brush" style="box-sizing:border-box;">纪元龙虾</strong></p></section></section>';
$result=preg_replace('/<section/','<div',$str);
$result=preg_replace('/<\/section/','</div',$result);
echo $result;
?>
运行结果
<div style="font-size:16px;"><div class="_135editor"><p><strong class="135brush" style="box-sizing:border-box;">纪元龙虾</strong></p></div></div>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-06-13
替换成div标签
相似回答