preg_replace of annonying html标签和反斜杠php

时间:2014-10-14 08:26:06

标签: php html preg-replace

我需要帮助preg替换并计算它 我有像

这样的内容
<a href=\http://www.example.com\ target=\_blank\ title=\Cleo's Vip Room\>
<img src=\linkurl.tld\ />
<table style=\font-family:Arial, sans-serif;\ border=\0\ cellspacing=\0\ cellpadding=\0\ align=\center\>

并且有许多用途\而不是&#34; 我想将它们全部删除,只保留URL和图像,如[URL] url.tld [/ URL]和[img]图像源[/ img],用于论坛bbcode

请帮助

1 个答案:

答案 0 :(得分:1)

试试这个:

$html = "<a href=\http://www.example.com\ target=\_blank\ title=\Cleo's Vip Room\>
<img src=\linkurl.tld\ />
<table style=\font-family:Arial, sans-serif;\ border=\0\ cellspacing=\0\ cellpadding=\0\ align=\center\>";

$newHtml = preg_replace('/\\\\/', '"', $html);

echo $newHtml;