php:html富文本提取text普通文本内容
导读:<?php function getPlainTextFromHtml($html { // Remove the HTML tags $html = strip_tags($html ; // Co...
?php
function getPlainTextFromHtml($html)
{
// Remove the HTML tags
$html = strip_tags($html);
// Convert HTML entities to single characters
$html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
$html_len = mb_strlen($html, 'UTF-8');
// Make the string the desired number of characters
// Note that substr is not good as it counts by bytes and not characters
$html = mb_substr($html, 0, strlen($html), 'UTF-8');
return $html;
}
echo getPlainTextFromHtml('p>
主任医师,教授,a>
硕士生导师/a>
,中山医学院医疗系毕业。\/p>
');
// 主任医师,教授,硕士生导师,中山医学院医疗系毕业。
参考
php 提取html 文本内容,正文内容
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: php:html富文本提取text普通文本内容
本文地址: https://pptw.com/jishu/7918.html
