PHP下,截取中文字符串
2011-11-23 11:17
197 查看
One Chinese char in
UFT-8 encoding holds 3 bytes, and let's suppose that your string is encoded by 'UTF-8', and you've already set your page's encoding method is 'UTF-8',
then the following lines will make it:
Just stop here, since it get the work done. And will be back soon!
REFs:
http://blog.xuite.net/chenbruse/bruse/13351768
http://blog.linym.net/archives/74
http://zoearthmoon.blogspot.com/2010/03/phpsubstr.html
http://www.wretch.cc/blog/herbjoyce/9665218
UFT-8 encoding holds 3 bytes, and let's suppose that your string is encoded by 'UTF-8', and you've already set your page's encoding method is 'UTF-8',
then the following lines will make it:
$match->homegroup = '丙組'; echo substr($match->homegroup, 0, 3); // works, will output '丙' , but not good echo mb_substr($match->homegroup, 0, 3); // works, will output '丙' , but not good echo mb_substr($match->homegroup, 0, 1, "UTF-8"); // works, will output '丙'
Just stop here, since it get the work done. And will be back soon!
REFs:
http://blog.xuite.net/chenbruse/bruse/13351768
http://blog.linym.net/archives/74
http://zoearthmoon.blogspot.com/2010/03/phpsubstr.html
http://www.wretch.cc/blog/herbjoyce/9665218
相关文章推荐
- PHP截取中文字符串方法合集
- php截取中文字符串不乱码的方法
- 几个支持中文的PHP字符串截取函数
- PHP使用mb_substr()解决中文字符串截取乱码问题
- 收藏几个支持中文的PHP字符串截取函数
- php中如何截取中文字符串
- php中计算中文字符串长度、截取中文字符串
- php 中文字符串截取
- PHP 中文字符串截取
- PHP截取中文字符串方法总结
- PHP截取中文字符串方法总结
- php中如何截取中文字符串?
- PHP截取含中文的混合字符串长度的函数
- PHP截取中文字符串方法
- 多个PHP中文字符串截取函数
- php中截取中文字符串的代码小结
- php用正则表达式截取中文字符串的函数
- PHP 截取中文字符串 UTF-8
- PHP substr()截取字符串时,中文出现乱码的问题解决【转】
- 收藏几个支持中文的PHP字符串截取函数