PHP wordwrap() Function
The wordwrap()
function is used to wraps a string into new lines when it reaches a specific length.
Syntax
wordwrap(string,width,break,cut)
- string - (Required) specify the string to check break up into the line.
- width - (Required) specify the maximum line width.default is 75.
- break - (Required) specify the characters to use break. Defauly '\n'.
- cut - (Required) Specify whether words longer than the width should be wrapped
false -default(No wrap)
true - wrap
Example
<?php $a = "An example of the wordwrap() function to break the string.when it reaches a specified length"; echo wordwrap($a,15,"<br>\n"); ?>
Output
An example of the wordwrap() function to break the string.when it reaches a specified length