当前位置:Gxlcms > PHP教程 > PHPHTML富文本遇到某些字眼截取

PHPHTML富文本遇到某些字眼截取

时间:2021-07-01 10:21:17 帮助过:27人阅读

/** * @author      default7 * @description 裁剪HTML,当他遇到某段文字的时候 * * @param        $htmlContent * @param string $meetStr * * @return string */function cutHtmlWhenMeet($htmlContent, $meetStr = ''){    if (!empty($meetStr)) {        $posMeet = mb_strpos($htmlContent, $meetStr, null, 'UTF-8');        if ($posMeet !== false) {            $htmlEnd = mb_substr($htmlContent, 0, $posMeet, 'UTF-8');            $posEnd = mb_strrpos($htmlEnd, '= $posMeet) {                    break;                }            }            $htmlContent = mb_substr($htmlContent, 0, $posEnd, 'UTF-8');        }    }    return $htmlContent;}

人气教程排行