The
wordwrap() string function in PHP will force line breaks in a string at a length that you specify. If you apply the fourth parameter it will wrap long continuous words people input into your web apps, that may mess up your layout if not adjusted.
<?php
$myString = "Develop PHP is the best place for beginners to learn PHP.";
$myString = wordwrap($myString, 24, "<br />");
echo $myString;
echo "<hr />";
$myString = "Wrap long words hahahahahahahahahahahahahahahahahaha";
$myString = wordwrap($myString, 24, "<br />", true);
echo $myString;
?>
Develop PHP is the best
place for beginners to
learn PHP.
Wrap long words
hahahahahahahahahahahaha
hahahahahaha