faqts : Computers : Programming : Languages : PHP : Common Problems : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 20 people (75%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do you insert a word-wrap of 80char into a string?

Aug 31st, 2000 19:22
Chris Kings-Lynne, mike gifford, unknown unknown, http://www.php.net/manual/function.wordwrap.php


string wordwrap (string str [, int width [, string break]])
Wraps the string str at the column number specified by the (optional) 
width parameter. The line is broken using the (optional) break 
parameter. 
wordwrap() will automatically wrap at column 75 and break using '\n' 
(newline) if width or break are not given. 
Example 1. wordwrap() example
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap( $text, 20 );
echo "$newtext\n";
This appeared in PHP 4.0.2...
Chris