1.本版搜一下,faq里也有,截取中文字符串的函数mb_substr(PHP 4 >= 4.0.6)
mb_substr -- Get part of string
Description
string mb_substr ( string str, int start [, int length [, string encoding]])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.If encoding is omitted, internal encoding is assumed.encoding is character encoding. If it is omitted, internal character encoding is used.See also mb_strcut(), mb_internal_encoding()
2.不知道
mb_substr -- Get part of string
Description
string mb_substr ( string str, int start [, int length [, string encoding]])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.If encoding is omitted, internal encoding is assumed.encoding is character encoding. If it is omitted, internal character encoding is used.See also mb_strcut(), mb_internal_encoding()
2.不知道
解决方案 »
- 为什么我的本地环境不能解析子目录下的PHP文件
- 如何限定EXEC等系统执行函数的执行目录?
- 求一MySQL语句或解决问题思路
- 大家觉得写一个PHP连接池性质的扩展有没有用?
- 关于php生成html的问题!
- 我想用XMLHttpRequest 提交form里的数据到a.php,这个文件怎么得到这个数据啊?
- 如何把留言的内容传到叶面上面阿
- ◆◇php终极问题◆◇:如何用php新建一个文件,并在限定时间以后删除该文件!!
- 下面这段代码,看一下代码有什么问题,到下一页SESSION就没有了.
- 我现在考虑离开CSDN了,那里还有人气旺的论坛啊,推荐一下!
- ◆◆◆编码的问题!◆◆◆
- 关于注册系统自动回复确认信的问题
/* 函数 sub_str($text, $length)
** 功能 从文本中截取指定长度字符串,考虑了对中文的处理
** 参数 $text 要截取的文本
** 参数 $length 要截取的字符串长度
*/
function sub_str($text, $length)
{
for ($i=0; $i<$length; $i++)
{
$chr = substr($text, $i, 1);
if (ord($chr) > 0x80)//字符是中文
{
$length++;
$i++;
} }
$str = substr($text, 0, $length);
return $str;
}
2. 右键单击X,选择显示图片,即可