Home >Backend Development >PHP Tutorial > 关于substr截取字符的有关问题

关于substr截取字符的有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:48:52768browse

关于substr截取字符的问题
字符串中有英文,中文,日文。请问怎么截取的长度差很远,有些很长,有些很短

以下为代码

<br />
   $prna=$row['product_name']; <br />
		if(strlen($prna)>20)<br />
		{<br />
		$prna=substr($prna,20)."…"; <br />
		echo $prna;<br />
		}<br />
		else<br />
		{<br />
		echo $prna;<br />
		}	<br />



------解决方案--------------------
mb_substr
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
Previous article: jpgraph路径有关问题 Next article: 分享一起代码