2016-09-27 67 views
0
$string = "<h2> <div class="OutlineElement Ltr SCX116040423" style="margin: 0px; padding: 0px; font-family: 'Segoe UI', Tahoma, Verdana, sans-serif; font-size: 8px; font-weight: normal;"> <p class="MsoNormal">Residents of the northeast are discovering that Branford Hall has become one of the fastest and most effective ways to begin a high growth career.<o:p>" 

$string = preg_replace("/&#?[a-z0-9]+;/i","",$string); 

我需要出去爲純文本HTML實體和元素從字符串明文:需要提取包含使用PHP

東北部的居民們發現,布蘭福德館已成爲最快的國家之一以及開始高增長事業的最有效途徑。

請幫助我糾正preg_replace正則表達式?

回答

2

PHP有一些內置的功能,應該是更方便了這一點:

$string = strip_tags(html_entity_decode($string));