It is convenient and useful to break a line by the number of words in each line you specify.
// Text_wrap ($ text, $ max_width, $ html_type)
// $ Text to be formatted
// $ Length of max_width-format
// $ Html_type format
Function text_wrap ($ text, $ max_width, $ html_type)
{
// $ Cnt keeps track of the position of t
// He last break
$ Cnt = 0;
If (! Strcmp ("PRE", $ html_type ))
$ Line_break = "n ";
Else
$ Line_break ="
N ";
Echo "<$ html_type> n ";
For ($ I = $ max_width; $ I <strlen ($ text); $ I + = $ max_width)
{
$ Width = $ max_width;
While ($ text [$ I]! = & $ Text [$ I]! = N & $ text [I]! = T)
{
$ I --;
$ Width --;
}
Echo substr ($ text, $ cnt, $ width), $ line_break;
$ Cnt = $ I + 1;
}
$ Last_line = substr ($ text, $ cnt );
If ($ last_line [0]! =)
Echo substr ($ text, $ cnt );
Else
Echo substr ($ text, $ cnt + 1 );
Echo" N ";
}
// Below is a test. You can save this article for another try.
$ Line = "" When considering the use of a server side ";
$ Line = "$ line language, such as php3, you have to weigh ";
$ Line = "$ line the load on your server against the benefits ";
$ Line = "$ line of the language. For example, especially ";
$ Line = "$ line regards to php3, the benefits are worth ";
$ Line = "$ line sacrifice. For some tasks it is unimaginable ";
$ Line = "$ line how difficult they wocould be without server side ";
$ Line = "$ line scripting. There is certainly something to be ";
$ Line = "$ line said for web content that is dynamic -- it ";
$ Line = "$ line keeps people coming back." -- The Webmaster ";
Text_wrap ($ line, 60, "BLOCKQUOTE"); // call a function
?>