PHP Programing language

wordwrap() Function in PHP
Previous Home Next
adplus-dvertising

wordwrap()

The wordwrap() function wraps a string into new lines when it reaches a specific length.

Syntax:
wordwrap(string,width,break,cut)

In above syntax, "string" specifies the string to break up into lines, "width" specifies the maximum line width default is 75, "break" specifies the characters to use as break default is "\n" and "cut" specifies whether words longer than the specified width should be wrapped means if it is 'FALSE': Default or No-wrap and 'TRUE': Wrap.

Example:

<?php
$str = "Always bear in mind that your own resolution 
	to succeed is more important than any one thing.";
echo wordwrap($str,15,"<br>\n");
?>

Output:


Always bear in
mind that your
own resolution
to succeed
is more
important than
any one thing.

Previous Home Next