PHP truncates headers and is compatible with utf8 and gb2312 encoding_PHP tutorial

WBOY
Release: 2016-07-21 16:12:38
Original
876 people have browsed it

Copy code The code is as follows:

45){$str =utf8Substr($r[title],0,15)."...";}else{$str=$r[title];}echo $str; ?>
//Intercept utf8 string
function utf8Substr($str, $from, $len)
{
return preg_replace('#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0 ,'.$from.'}'.
'((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$len.'}).*# s',
'$1',$str);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313607.htmlTechArticleCopy the code as follows: ?php if(strlen($r[title])45){$str=utf8Substr ($r[title],0,15)."...";}else{$str=$r[title];}echo $str; ? //Intercept utf8 string function utf8Substr($str, $fr ...
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