All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
c#编程中学习数据结构的必要性
讲述PHP中Session的概念_php资料_编程技术
ASP.NET&Spring.NET&NHibernate最佳实践(一)——目录_[Asp.Net教程]
LINQ体验(14)——LINQ,to,SQL语句之存储过程_[Asp.Net教程]
PHP:实现给上传图片加水印的程序代码_php资料_编程技术
.NET,2.0,SqlDependency快速上手指南_[Asp.Net教程]
ASP.NET,2.0高级数据处理之数据绑定语法_.net资料_编程技术
PHPUnit袖珍指南之自动测试_[PHP教程]
如何在十天内学会php之第一天_[PHP教程]
ASP.NET编程中的十大技巧_[Asp.Net教程]
Reading number is top 10 pictures
The world's top ten most beautiful railway station2
西游四格漫画(六)
2012 national geographic daily picture4
More attractive than sora aoi4
开始让人感动,后来......
2012 national geographic daily picture6
做运动的校花1
The terra-cotta warriors3
Take you to walk into the most true north Korea rural4
A man's favorite things3--ZhouWeiTong
Download software ranking
传奇私服架设教程
VC++6.0培训教程
Macromedia Dreamweaver 8
变速齿轮3.26
c#程序设计案例教程
Kung fu panda - the secret of the teacher
金山office2007
Sora aoi‘s film--Lust fan wall
Boxer's Top ten classic battle10
Boxer's Top ten classic battle8
aaa published in(发表于) 2013/12/24 5:50:51 Edit(编辑)
PHP的mb_substr和mb_strcut的区别_php资料_编程技术

PHP的mb_substr和mb_strcut的区别_php资料_编程技术

PHP的mb_substr和mb_strcut的区别_php资料_编程技术-你的首页-uuhomepage.com

php的mbstring扩展模块提供了多字节字符的处理能力,平常最常用的就是用mbstring来切分多字节的中文字符,这样可以避免出现半个字符的情况,由于是php的扩展,它的性能也要比一些自定义的多字节切分函数要好上一些。

mbstring extension提供了几个功能类似的函数,mb_substr和mb_strcut,看看手册上对它们的解释。

mb_substr
mb_substr() returns the portion of str specified by the start and length parameters.

mb_substr() performs multi-byte safe substr() operation based on number of characters. Position is counted from the beginning of str. First character's position is 0. Second character position is 1, and so on.

mb_strcut
mb_strcut() returns the portion of str specified by the start and length parameters.

mb_strcut() performs equivalent operation as mb_substr() with different method. If start position is multi-byte character's second byte or larger, it starts from first byte of multi-byte character.

It subtracts string from str that is shorter than length AND character that is not part of multi-byte string or not being middle of shift sequence.

举个例子来说,有一段文字, 分别用mb_substr和mb_strcut来做切分:

PLAIN TEXT
CODE:
$str = '我是一串比较长的中文-www.webjx.com';

echo "mb_substr:" . mb_substr($str, 0, 6, 'utf-8');

echo "
";

echo "mb_strcut:" . mb_strcut($str, 0, 6, 'utf-8');
?>
输出结果如下:

mb_substr:我是一串比较
mb_strcut:我是





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.