Current Location: Home> Function Categories> wordwrap

wordwrap

Break string to a specified number of strings
Name:wordwrap
Category:String
Programming Language:php
One-line Description:The break string is a specified number of strings.

Definition and usage

wordwrap() function performs line-folding processing on strings according to the specified length.

Comment: This function may leave blank characters at the beginning of the line.

Example

Example 1

Fold the string according to the specified length:

 <?php
$str = "An example of long words: Supercalifragulistic" ;
echo wordwrap ( $str , 15 , "<br>\n" ) ;
?>

Try it yourself

Example 2

Use all parameters:

 <?php
$str = "An example of a long word is: Supercalifragulistic" ;
echo wordwrap ( $str , 15 , "<br>\n" , TRUE ) ;
?>

Try it yourself

Example 3

Fold the string:

 <?php
$str = "An example of a long word is: Supercalifragulistic" ;
echo wordwrap ( $str , 15 ) ;
?>

HTML output of the above code (please check the source code):

 < ! DOCTYPE html >
< html >
< body >
An example of a
long word is :
Supercalifragulistic
< / body >
< / html >

The browser output of the above code:

 An example of long words: Supercalifragulistic

Try it yourself

grammar

 wordwrap ( string , width , break , cut )
parameter describe
string Required. Specifies the string to be folded.
width Optional. Specify the maximum row width. The default is 75.
break Optional. Specifies the characters used as delimiters (string break characters). The default is "\n".
cut

Optional. Specifies whether to fold lines of words larger than the specified width:

  • FALSE - Default. No-wrap
  • TRUE - Folding
Similar Functions
Popular Articles