我有一个HTML表单,要求用户粘贴一些代码:
<!-- Facebook Badge START -->
<a href="https://www.facebook.com/alex.gk" target="_TOP" style="font-family: "lucida grande",tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Alex Gk">Alex Gk</a>
<span style="font-family: "lucida grande",tahoma,verdana,arial,sans-serif; font-size: 11px; line-height: 16px; font-variant: normal; font-style: normal; font-weight: normal; color: #555555; text-decoration:none;"> | </span>
<a href="https://www.facebook.com/badges/" target="_TOP" style="font-family: "lucida grande",tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Δb7;μιουργήστε το δικό σας διακριτικό!">Δημιουργήστε το δικό σας διακριτικό</a><br/>
<a href="https://www.facebook.com/alex.gk" target="_TOP" title="Alex G">
<img src="https://badge.facebook.com/badge/1565383.3437.1745257502.png" style="border:0px;" />
</a>
<!-- Facebook Badge END -->
我想要的PHP只是保留下面的部分,以便用户粘贴整个代码 但在提交表格后,它只保留以下部分。
<a href="https://www.facebook.com/alex.gk" target="_TOP" title="AlexG">
<img src="https://badge.facebook.com/badge/1383.3437.1745257502.png" style="border:0px;" />
</a>
答案 0 :(得分:0)
您是否尝试过strip_tags()
?
$text = strip_tags($text, '<b><strong');