经测试代码如下:
/**
* wordwrap如何按照用户指定的长度进行换行
*
* @param
* @arrange (512.笔记) jb51.cc
**/
// create a long text for testing:
$long_text = 'This is a long text to demonstrate the usage of the ';
$long_text .= 'wordwrap function. ';
$long_text .= 'Fooooooooooooooooobar,just fooling around';
// Syntax: wordwrap(input string,line max. width,break chars,cut words)
$new_text = wordwrap($long_text,15,"<br/>\n",true);
print $new_text;
/*
The output will be:
This is a long<br/>
text to<br/>
demonstrate the<br/>
usage of the<br/>
wordwrap<br/>
function.<br/>
Foooooooooooooo<br/>
ooobar,just<br/>
fooling around
*/
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/