php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #24823 wordwrap example clarification
Submitted: 2003-07-26 19:06 UTC Modified: 2003-07-27 06:17 UTC
From: curt at czirzow dot dyndns dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2003-07-26 19:06 UTC] curt at czirzow dot dyndns dot org
Description:
------------
function wordwrap:

----
Example 1:
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap( $text, 20 );
echo "$newtext\n";

Example 1 output:
The quick brown fox
jumped over the
lazy dog.
---

This is rather misleading to new users, they seem to be expecting their output to be shown with carriage returns in html (since php defaults with text/html mime-type.) Perhaps using a <pre> tag around output:

echo "<pre>$newtext</pre>"

Or using the break parameter in the function:

$newtext = wordwrap( $text, 20, '<br>');

This applies to both example 1 and 2.

Thanks.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-27 06:17 UTC] betz@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 10:00:01 2025 UTC