Hướng dẫn php wrap string

❮ PHP String Reference

Example

Wrap a string into new lines when it reaches a specific length:

Try it Yourself »

Definition and Usage

The wordwrap[] function wraps a string into new lines when it reaches a specific length.

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

Syntax

wordwrap[string,width,break,cut]

Parameter Values

ParameterDescription
string Required. Specifies the string to break up into lines
width Optional. Specifies the maximum line width. Default is 75
break Optional. Specifies the characters to use as break. Default is "\n"
cut Optional. Specifies whether words longer than the specified width should be wrapped:
  • FALSE - Default. No-wrap
  • TRUE - Wrap

Technical Details

Return Value:PHP Version:Changelog:
Returns the string broken into lines on success, or FALSE on failure.
4.0.2+
The cut parameter was added in PHP 4.0.3

More Examples

Example

Using all parameters:

Try it Yourself »

Example

Wrap a string into new lines:

The HTML output of the code above will be [View Source]:




An example of a
long word is:
Supercalifragulistic

The browser output of the code above will be:

An example of a long word is: Supercalifragulistic

Try it Yourself »

❮ PHP String Reference


this is my first questions in stack overflow. i want build search result in php. i have code like below:

Chủ Đề