wordwrap
Break string to a specified number of strings
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.
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
Use all parameters:
<?php $str = "An example of a long word is: Supercalifragulistic" ; echo wordwrap ( $str , 15 , "<br>\n" , TRUE ) ; ?>
Try it yourself
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
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:
|