Re: [請益] 怎樣讓表格欄位的高度固定
※ 引述《nomoty (朋友??)》之銘言:
: 我有一個表格欄位是接收使用者輸入的值,但輸入值
: 的大小並不是固定的,因此當輸入的字多的時候,欄
: 位高度就變的很大
: 以下是我欄位的程式碼
: <td style="word-wrap:break-word;word-break:break-all;"width="200" height="50" > <font face="標楷體"><?php echo
: $row_f1['content']; ?></font></td>
: 已經將欄位寬度設定為固定大小自動換行,但要怎樣能讓欄位只顯示符合大小,
: 其他多餘的字就隱藏
原文:http://blog.wu-boy.com/2007/05/18/104/
適用於 Big5:
function cut_word($text, $num){
if(strlen($text) > $num) {
for($i=0;$i<$num;$i++) {
$ch=substr($text,$i,1);
if(ord($ch)>127) $i++;
}
$text= substr($text,0,$i).".";
}
return $text;
}
用於 UTF-8 跟 Big5
function bite_str($string, $start, $len, $byte=3)
{
$str = "";
$count = 0;
$str_len = strlen($string);
for ($i=0; $i<$str_len; $i++) {
if (($count+1-$start)>$len) {
$str .= "...";
break;
} elseif ((ord(substr($string,$i,1)) <= 128) && ($count < $start)) {
$count++;
} elseif ((ord(substr($string,$i,1)) > 128) && ($count < $start)) {
$count = $count+2;
$i = $i+$byte-1;
} elseif ((ord(substr($string,$i,1)) <= 128) && ($count >= $start)) {
$str .= substr($string,$i,1);
$count++;
} elseif ((ord(substr($string,$i,1)) > 128) && ($count >= $start)) {
$str .= substr($string,$i,$byte);
$count = $count+2;
$i = $i+$byte-1;
}
}
return $str;
}
或者利用:mb_substr 都可以
--
Appleboy Blog: http://blog.Wu-Boy.com 電腦技術、美食介紹、旅遊資訊
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.69.81.52
推
03/28 22:17, , 1F
03/28 22:17, 1F
→
03/28 22:17, , 2F
03/28 22:17, 2F
→
03/28 22:41, , 3F
03/28 22:41, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章