Oni*_*ion 10 php styles inline
我使用PHP输出一些富文本.如何完全去除内联样式?
文本将直接从MS Word或OpenOffice粘贴到使用TinyMCE的文本中,TinyMCE是一种富文本编辑器,允许您向文本添加基本HTML格式.但是我想删除内联样式
标签(见下文),但保留
标记自己.
<p style="margin-bottom: 0cm;">A patrol of Zograth apes came round the corner, causing Rosette to pull Rufus into a small alcove, where she pressed her body against his. “Sorry.” She said, breathing warm air onto the shy man's neck. Rufus trembled.</p>
<p style="margin-bottom: 0cm;"> </p>
<p style="margin-bottom: 0cm;">Rosette checked the coast was clear and pulled Rufus out of their hidey hole. They watched as the Zograth walked down a corridor, almost out of sight and then collapsed next to a phallic fountain. As their bodies hit the ground, their guns clattered across the floor. Rosette stopped one with her heel and picked it up immediately, tossing the other one to Rufus. “Most of these apes seem to be dying, but you might need this, just to give them a helping hand.”</p>
Run Code Online (Sandbox Code Playgroud)
Jak*_*e N 28
我很快将它们放在一起,但对于"内联样式"(!),你需要类似的东西
$text = preg_replace('#(<[a-z ]*)(style=("|\')(.*?)("|\'))([a-z ]*>)#', '\\1\\6', $text);
Run Code Online (Sandbox Code Playgroud)
Col*_*mes 11
这是我从Crozin的答案中得出的preg_replace解决方案.这个允许使用锚标记修复问题的样式属性之前和之后的属性.
$value = preg_replace('/(<[^>]*) style=("[^"]+"|\'[^\']+\')([^>]*>)/i', '$1$3', $value);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19974 次 |
| 最近记录: |