CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: seven minus zero?
(Example: nine)

The Note You're Voting On

Kevin
19 years ago
To phpkid:

This is a much simpler solution.

<?php
function longWordWrap($string) {
$string = str_replace("\n", "\n ", $string); // add a space after newline characters, so that 2 words only seperated by \n are not considered as 1 word
$words = explode(" ", $string); // now split by space
foreach ($words as $word) {
$outstring .= chunk_split($word, 12, " ") . " ";
}
return
$outstring;
}
?>

<< Back to user notes page

To Top