douyu1656 2015-01-24 09:50
浏览 16

在所有标记(如<a>)之前插入其他html标记

I would like to modify html string from wysiwyg. After saving data to database my text looks like:

   something bla bla
<p> something bla bla bla ba</p>
<h3 class"blabla"> bla bla bla</h3>
<p class"smtg"> another text bla bla <a href="blabla" class="blabla2">Nice url</a> </p>
<ul>
<li>lilislist</li>
<li>lilislist</li>
<li>lilislist</li>
<li>lilislist</li>
</ul>
<img src="blabla.jpg">
bleblebleblebe
<a href="blabla" class="blabla2" target="" id="notblabla">Nice url2</a>

Of course this is only example. I would like to add additional paragraf(eg.<p class="special">special text</p>) before each <a> and <img> element. However elements <a> and <img> must keep all attributes etc.

I know that this is easy to do with jquery but I can't use JavaScript here. It must be done by PHP.

Do you know how I can do it? Let's suppose that my string with html tags is assigned to $DBdata.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 目详情-五一模拟赛详情页
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line