@ -662,7 +662,7 @@ PHP_FUNCTION(wordwrap)
else {
/* Multiple character line break or forced cut */
if (linelength > 0) {
newtextlen = textlen + (textlen/linelength) * breakcharlen + 1;
newtextlen = textlen + (textlen/linelength + 1) * breakcharlen + 1;
}
newtextlen = textlen * (breakcharlen + 1) + 1;
@ -27,6 +27,8 @@ $tests = <<<TESTS
"12345|12345|67890" === wordwrap("12345 1234567890", 5, "|", 1)
"123|==1234567890|==123" === wordwrap("123 1234567890 123", 10, "|==", 1)
TESTS;
include('tests/quicktester.inc');