Easy Tutorial
❮ Php Json Pdostatement Errorinfo ❯

PHP wordwrap() Function

PHP String Reference Manual

Example

Wrap a string to a specified length:


Definition and Usage

The wordwrap() function wraps a string to a specified length.

Note: This function may leave spaces at the beginning of a line.


Syntax

Parameter Description
string Required. Specifies the string to be wrapped.
width Optional. Specifies the maximum line width. Default is 75.
break Optional. Specifies the character used as the break. Default is "\n".
cut Optional. Specifies whether to wrap words longer than the specified width: FALSE - Default. Do not wrap<br> TRUE - Wrap

Technical Details

Return Value: Returns the wrapped string if successful. Returns FALSE if unsuccessful.
PHP Version: 4.0.2+
--- ---
Changelog: The cut parameter was added in PHP 4.0.3.
--- ---

More Examples

Example 1

Using all parameters:

Example 2

Wrapping a string:

The HTML output of the above code (view source) is:

The browser output of the above code is:


❮ Php Json Pdostatement Errorinfo ❯