Req #22487 [Opn]: wordwrap removes space at break, could be optional?

From: Date: Tue, 11 Mar 2014 13:19:43 +0000
Subject: Req #22487 [Opn]: wordwrap removes space at break, could be optional?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184718@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=22487&edit=1

 ID:                 22487
 Updated by:         datibbaw@php.net
 Reported by:        mikael at whip3 dot net
 Summary:            wordwrap removes space at break, could be optional?
 Status:             Open
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Windows XP
 PHP Version:        4.3.0
 Block user comment: N
 Private report:     N

 New Comment:

This would accomplish what you want without using wordwrap().

echo join("X", str_split($str, 13));


Previous Comments:
------------------------------------------------------------------------
[2011-05-03 08:57:02] breiteseite1337 at gmail dot com

I fully agree with mikael. An optional parameter which controls this behaviour would be very useful.

For example: You create a ics/ical file and you want to break after 75 characters
(http://tools.ietf.org/html/rfc5545#section-3.1)

wordwrap could make that easy. But it may remove spaces. So your links may break and words may get
unintentionally concatenated.

So a extra parameter makes sense in my opinion.

+1

P.S.: a workaround for the above-mentioned problem is to replace the whitespace character with an
extra symbol (e.g. '^'), wordwrap() and replace the extra symbol back to a whitespace.

------------------------------------------------------------------------
[2003-03-01 05:52:54] mikael at whip3 dot net

The function wordwrap removes on space character if a break occurs between two words. This is not
always desired behavior.

For example:

echo wordwrap('abc abc abc    abc', 13, 'X', 1);

Note: 4 spaces between last pair

Results in:
abc abc abc  X abc

Two spaces left before the break and one after. One space gets removed. The same happens if we only
have one space where a line break occurres, leaving us with only a line break between the words.

/ mikael



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=22487&edit=1


Thread (5 messages)

« previous php.bugs (#184718) next »