我有這樣的示例代碼之間移除文本:PHP - 使用用strip_tags來去掉標籤
<?php
$string='Left text from tag <div title="hello world" class="CSS">What is <b>going on</b> here?<br> Calm up <em>right now</em>.</div> Right text. Possible another <div title="" class="DD">tag..</div> but not always.';
echo strip_tags($string);
?>
這段代碼的結果是:
Left text from tag What is going on here? Calm up right now. Right text. Possible another tag.. but not always.
然而,我的目標是消除所有文本(包括標籤)通過此strip_tags函數移除的標籤之間。 IE瀏覽器。結果應該是:
Left text from tag Right text. Possible another but not always.
我知道它可以用了preg_replace來完成,但是它是太慢了,所以也許有一種更快的解決方案。(沒有必然的關係用strip_tags功能)。
是的,但它可以被不使用的preg_replace完成(即我需要一個更快的解決方案。)。由於strip_tags知道要替換什麼,所以也許它可以用來刪除發現strip_tags之間的文字.. – Tom
我不認爲有任何直接的解決方案,您的問題在構建函數中使用PHP。你必須以某種方式使用REGEX。 –