+
95
-

php怎么从一段html文档中提取一定长度的中文文本摘要?

php

请问php怎么从一段html文档中提取一定长度的中文文本摘要?

网友回复

+
15
-

先将html标签去除,然后在进行文字长度截取,超过的话就加省略号,示例代码如下:

<?php
function getplaintextintrofromhtml($html, $numchars) {
    // Remove the HTML tags
    $html = strip_tags($html);

    // Convert HTML entities to single characters
    $html = html_entity_decode($ht...

点击查看剩余70%

我知道答案,我要回答