Home >Backend Development >PHP Tutorial >PHP清除html、css、js格式并去除空格的PHP函数

PHP清除html、css、js格式并去除空格的PHP函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 13:03:401032browse

function cutstr_html($string,$length=0,$ellipsis='…'){<br />	$string=strip_tags($string);<br />	$string=preg_replace('/\n/is','',$string);<br />	$string=preg_replace('/ | /is','',$string);<br />	$string=preg_replace('/ /is','',$string);<br />	preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/",$string,$string);<br />	if(is_array($string)&&!empty($string[0])){<br />		if(is_numeric($length)&&$length){<br />			$string=join('',array_slice($string[0],0,$length)).$ellipsis;<br />		}else{<br />			$string=implode('',$string[0]);<br />		}<br />	}else{<br />		$string='';<br />	}<br />	return $string;<br />}


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