本范例演示了php中wordwrap如何按照用户指定的长度进行换行
// 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 */