From:             php at ter dot dk
Operating system: Linux
PHP version:      4.3.6
PHP Bug Type:     Strings related
Bug description:  wordwrap counts extra character for following lines

Description:
------------
wordwrap will wrap at length for the first wrapped line and length-1 for
the following lines in the following code.

My guess is that it counts the space where the text is wrapped before, for
the following line (even though the space is removed in the output).

The reproducible code was tested under Linux (PHP4.3.6), AIX (PHP4.3.2)
and FreeBSD (PHP4.3.4). I haven't put up a test where several spaces
follow at the wrapping-point, but it might be tested as well.


Reproduce code:
---------------
<?php
$text = "Some text";
$string = "$text $text $text $text";
print nl2br(wordwrap($string,9));
?>

(nls2br() only added for easy same result when not using nl2br(), just
look in the HTML-source instead)


Expected result:
----------------
Some text
Some text
Some text
Some text

Actual result:
--------------
Some text
Some
text
Some
text
Some
text

-- 
Edit bug report at http://bugs.php.net/?id=28386&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28386&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28386&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28386&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28386&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28386&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28386&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28386&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28386&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28386&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28386&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28386&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28386&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28386&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28386&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28386&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28386&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28386&r=float

Reply via email to