从表单字段中分解函数

时间:2014-02-26 07:50:25

标签: php forms text explode

我有一个HTML表单,要求用户粘贴一些代码:

<!-- Facebook Badge START -->

<a href="https://www.facebook.com/alex.gk" target="_TOP" style="font-family: &quot;lucida grande&quot;,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: &quot;lucida grande&quot;,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;">&nbsp;|&nbsp;</span>

<a href="https://www.facebook.com/badges/" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="&#x394;&#3b7;&#x3bc;&#x3b9;&#x3bf;&#x3c5;&#x3c1;&#x3b3;&#x3ae;&#x3c3;&#x3c4;&#x3b5; &#x3c4;&#x3bf; &#x3b4;&#x3b9;&#x3ba;&#x3cc; &#x3c3;&#x3b1;&#x3c2; &#x3b4;&#x3b9;&#x3b1;&#x3ba;&#x3c1;&#x3b9;&#x3c4;&#x3b9;&#x3ba;&#x3cc;!">Δημιουργήστε το δικό σας διακριτικό</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>

1 个答案:

答案 0 :(得分:0)

您是否尝试过strip_tags()

$text = strip_tags($text, '<b><strong');