Home  >  Article  >  Backend Development  >  php去除html标签并截取中文字符

php去除html标签并截取中文字符

WBOY
WBOYOriginal
2016-06-20 12:52:14907browse

系统自带的函数mb_substr可以截取多字节的字符

strip_tags ― 从字符串中去除 HTML 和 PHP 标记

通过这两个函数便可解决

示例:

$str="我爱php";

echo mb_substr(strip_tags($str),0,3,'utf-8');

输出:我爱p



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn