php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28386 wordwrap counts extra character for following lines
Submitted: 2004-05-13 18:11 UTC Modified: 2004-05-13 19:44 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: php at ter dot dk Assigned:
Status: Closed Package: Strings related
PHP Version: 4.3.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at ter dot dk
New email:
PHP Version: OS:

 

 [2004-05-13 18:11 UTC] php at ter dot dk
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-13 19:44 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 13:01:29 2024 UTC