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

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

WBOY
Release: 2016-06-20 12:52:14
Original
930 people have browsed it

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

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

通过这两个函数便可解决

示例:

$str="我爱php";

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

输出:我爱p



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template