【发布时间】:2012-10-29 07:44:43
【问题描述】:
我有这个 preg_replace 模式和替换:
$patterns = array(
"/<br\W*?\/>/",
"/<strong>/",
"/<*\/strong>/",
"/<h1>/",
"/<*\/h1>/",
"/<h2>/",
"/<*\/h2>/",
"/<em>/",
"/<*\/em>/",
'/(?:\<code*\>([^\<]*)\<\/code\>)/',
);
$replacements = array(
"\n",
"[b]",
"[/b]",
"[h1]",
"[/h1]",
"[h2]",
"[/h2]",
"[i]",
"[/i]",
'[code]***HTML DECODE HERE***[/code]',
);
在我的字符串中,我想html_entity_decode 这些标签之间的内容:
<code> &lt; $gt; </code> 但保留我的数组结构以进行 preg 替换
所以这个:<code> &lt; &gt; </code> 将是这个:[code] < > [/code]
任何帮助将不胜感激,谢谢!
【问题讨论】:
标签: php regex decode html-entities bbcode