私はこの 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> < $gt; </code>
しかし、preg replace の配列構造を保持します
だからこれ:これ<code> < > </code>
になります:[code] < > [/code]
どんな助けでも大歓迎です、ありがとう!