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

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

WBOY
Release: 2016-06-13 11:20:56
Original
841 people have browsed it

关于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 />
Copy after login



------解决方案--------------------
mb_substr
Related labels:
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