php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29760 not correct works function, separators are placed accidentally
Submitted: 2004-08-19 16:19 UTC Modified: 2004-08-20 10:11 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sych at php dot com dot ua Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.0.0 OS: win2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sych at php dot com dot ua
New email:
PHP Version: OS:

 

 [2004-08-19 16:19 UTC] sych at php dot com dot ua
Description:
------------
not correct works function, separators are placed accidentally,


                 
                 

Reproduce code:
---------------
$text = wordwrap($row['text'], $param['words'], "#");  

Expected result:
----------------
Определение страны#пришедшего (PHP,#PostgreSQL) [p]Зачем#нам это#нужно[/p] В этой#статье будет#рассматриваться#способ определить#страну пришедшего#на Ваш сайт#пользователя.#Применять это

Actual result:
--------------
Определение страны пришедшего (PHP, PostgreSQL) [p]Зачем нам это нужно[/p] В этой статье будет рассматриваться способ определить страну пришедшего на Ваш сайтпользователя. Применять это #

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-19 16:22 UTC] tony2001@php.net
Err.. Forget it, clicked on a wrong link.

Please, provide more information, your example is not readable.
 [2004-08-19 16:30 UTC] sych at php dot com dot ua
Code1:
$text = wordwrap($string, 2, "#"); 

Result1:
word1#word2#word3#word4#word5#word6#word7#word8" 

Expected result1:
word1 word2# word3 word4# word5 word6# word7 word8


Code2:
$text = wordwrap($string, 3, "#"); 

Result2:
word1#word2#word3#word4#word5#word6#word7#word8" 

Expected result2:
word1 word2 word3# word4 word5 word6# word7 word8
 [2004-08-19 16:35 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.
 [2004-08-19 16:42 UTC] derick@php.net
Ah, there was already a script.

The wordwrap function seperates on characters (second parameter), not words.

Please read the documentation at http://php.net/wordwrap
 [2004-08-20 10:01 UTC] sych at php dot com dot ua
Yesterday I mistaken with examples there was heavy workday ,but function wordwrap works not correct with UTF-8 encoding.
 [2004-08-20 10:11 UTC] derick@php.net
wordwrap doesn't know about UTF and considers a multi-byte utf characters as as many characters as there are bytes in there. However, it will still break correctly on " " and "#" (or all other characters in the ascii range (0-127).

However, this is not a bug as it was only meant to work on iso-8859-*.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC