Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要使用php从包含html实体和元素的字符串中提取纯文本_Php_Regex_Preg Replace - Fatal编程技术网

需要使用php从包含html实体和元素的字符串中提取纯文本

需要使用php从包含html实体和元素的字符串中提取纯文本,php,regex,preg-replace,Php,Regex,Preg Replace,我需要输出为纯文本: 东北部的居民发现,布兰福德大厅已经成为开始高增长职业生涯的最快、最有效的方式之一 请帮助我更正preg_replace regex?PHP有一些内置函数,应该更方便: $string = "<h2> <div class="OutlineElement Ltr SCX116040423" style="margin: 0px; padding: 0px; font-family:

我需要输出为纯文本:

东北部的居民发现,布兰福德大厅已经成为开始高增长职业生涯的最快、最有效的方式之一


请帮助我更正preg_replace regex?

PHP有一些内置函数,应该更方便:

$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);

PHP有一些内置函数,应该更方便:

$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);