📄 00000030.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: thinkin (强强), 信区: Linux <BR>标 题: Word Wrap <BR>发信站: BBS 水木清华站 (Thu Feb 17 11:08:30 2000) <BR> <BR><?php <BR>// text_wrap( $text, $max_width, $html_type ) <BR>// $text - Text to be formatted (a string) <BR>// $max_width - Column on which to wrap <BR>// $html_type - Should be "PRE" or "BLOCKQUOTE" <BR>// <BR>// Written by Jeffrey D. Webster of Mirada Innovations. <BR>// <BR>// This particular function was written for our clients, so that <BR>// they could embed quotations from persons being interviewed <BR>// without having to pay much attention to how the text was <BR>// entered. <BR>// <BR>// Coming soon: Full justification function for <PRE> blocks. <BR>// <BR>// Version 1.0 <BR>Function text_wrap( $text, $max_width, $html_type ) <BR>{ <BR>// $cnt keeps track of the position of the last break <BR>$cnt = 0; <BR>if (!strcmp( "PRE", $html_type)) <BR> $line_break = "\n"; <BR>else <BR> $line_break = "<BR>\n"; <BR>echo "<$html_type>\n"; <BR>for ($i = $max_width; $i < strlen($text); $i += $max_width) <BR> { <BR> $width = $max_width; <BR> while ($text[$i] != ' ' && $text[$i] != '\n' && $text[i] != '\t') <BR> { <BR> $i--; <BR> $width--; <BR> } <BR> echo substr($text, $cnt, $width),$line_break; <BR> $cnt = $i+1; <BR> } <BR>$last_line = substr($text, $cnt); <BR>if ($last_line[0] != ' ') <BR> echo substr($text, $cnt); <BR>else <BR> echo substr($text, $cnt+1); <BR>echo "</$html_type>\n"; <BR>} <BR>// Do a little test. <BR>// An arbitrary string ;) <BR>$line = "\"When considering the use of a server side"; <BR>$line = "$line language, such as php3, you have to weigh"; <BR>$line = "$line the load on your server against the benefits"; <BR>$line = "$line of the language. For many, especially with"; <BR>$line = "$line regards to php3, the benefits are worth the"; <BR>$line = "$line sacrifice. For some tasks it is unimaginable"; <BR>$line = "$line how difficult they would be without server side"; <BR>$line = "$line scripting. There is certainly something to be"; <BR>$line = "$line said for web content that is dynamic -- it"; <BR>$line = "$line keeps people coming back.\" -- The Webmaster"; <BR>text_wrap($line, 60, "BLOCKQUOTE"); <BR>?> <BR> <BR>-- <BR> <BR>人生到处知何似? <BR> 应似飞鸿踏雪泥。 <BR> 泥上偶然留指爪, <BR> 鸿飞那复计东西! <BR> <BR> <BR>※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.37.191] <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -