update page now
Longhorn PHP 2026 - Call For Papers

Voting

: one plus one?
(Example: nine)

The Note You're Voting On

Kevin
20 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