} else if (text[current] == ' ') {
if (current - laststart >= linelength) {
newtext[current] = breakchar[0];
- laststart = current;
+ laststart = current + 1;
}
lastspace = current;
} else if (current - laststart >= linelength && laststart != lastspace) {
--- /dev/null
+--TEST--
+Bug #28386 (wordwrap() wraps text 1 character too soon)
+--FILE--
+<?php
+$text = "Some text";
+$string = "$text $text $text $text";
+echo wordwrap($string, 9);
+?>
+--EXPECT--
+Some text
+Some text
+Some text
+Some text