| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3079 人关注过本帖
标题:[分享][讨论][求助]请教:如何用PHP或JS控制:标题限制为4-20个汉字,内容1 ...
只看楼主 加入收藏
qiangzai8536
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2006-12-13
收藏
 问题点数:0 回复次数:2 
[分享][讨论][求助]请教:如何用PHP或JS控制:标题限制为4-20个汉字,内容10-3000个

如何用PHP或JS控制:标题限制为4-20个汉字,内容10-3000个汉字呢?此文本大致如下:谢谢!

<html>
<head>
</head>
<body>

<form method='POST' action='fbjypx_yjzlb.php?action=login'>
<table border="0" align="center" width="750" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="f2">密&nbsp;&nbsp;码:<input type="text" name="mm" size="20" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
</td>
</tr>
<tr>
<td width="100%" class="f2">标&nbsp;&nbsp;题:<input type="text" name="bt" size="40" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
<font class="f1">(23个汉字以内)</font></td>
</tr>
<br>
<tr>
<td width="100%" class="f2">内&nbsp;&nbsp;容:<font class="f1">(3000个汉字以内)</font></td>
</tr>
<tr>
<td width="100%" >
<textarea rows="20" name="nr" cols="105" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''"></textarea></td>
</tr>
<tr>
<td width="100%" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="提&nbsp;交">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重&nbsp;来"></td>
</tr>
</table>
</form>
</body>
</html>

搜索更多相关主题的帖子: head PHP 汉字 action 
2007-02-14 01:00
JavaEE5
Rank: 2
等 级:新手上路
威 望:4
帖 子:150
专家分:0
注 册:2006-12-24
收藏
得分:0 
strlen 获取字符串长度
substr 截取字符串

我喜欢JavaEE5,虽然对此不了解。
2007-05-25 10:02
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
收藏
得分:0 

PHP原有函数对中英混合的支持不大好

如果有mb_扩展直接用就可以了

没有的话用这个函数

function strSplit($s, $len) {
$end = '…';
$result = '';
$strLen = strlen($s);
if ($strLen <= $len) {
return $s;
}
$len -= 2;
for ($i=0; $i<$len && $i<$strLen; $i++) {
$c = $s[$i];
if (ord($c) < 0x80) {
$result .= $c;
} elseif ($i+1<$len) {
$result .= $s[$i++] . $s[$i];
}
}
return ($i < $strLen) ? ($result . $end) : $result;
}

echo strSplit('1234567', 10), '<br />';
echo strSplit('1234567890', 10), '<br />';
echo strSplit('1234中文567890abcdefghijkl', 10), '<br />';
echo strSplit('全部都是中文', 10), '<br />';
echo strSplit('全a部b都c是d中e文', 10), '<br />';

2007-05-25 12:35
快速回复:[分享][讨论][求助]请教:如何用PHP或JS控制:标题限制为4-20个汉字, ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014694 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved