|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
熟悉了PHP和MYSQL开发的要领之后,再回头看你写的那个留言本,你也许会怀疑那真的是你写的吗?当然,如果屋里还有鬼的话,也许是它写的-_- 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:
<?php
$str = '我是一串对照长的中文-www.webjx.com';
echo "mb_substr:" . mb_substr($str, 0, 6, 'utf-8');
echo "<br>";
echo "mb_strcut:" . mb_strcut($str, 0, 6, 'utf-8');
?>
输入了局以下:
mb_substr:我是一串对照
mb_strcut:我是
对我一点用处没有啊,我知道该怎么学,但是我想如何才能更快的学,一周速成,啊不,24小时速成那种,皮皮你有没? |
|