ID: 37846 User updated by: bugs dot php dot net at jonatan dot com Reported By: bugs dot php dot net at jonatan dot com Status: Bogus Bug Type: Strings related Operating System: Mac OS X 10.4.6 PHP Version: 5.1.4 New Comment:
You seem to be just as confused as the other guy. ;-) Sure, I guess the slight vagueness of the documentation could allow you to argue that wordwrap() wraps the third line incorrectly and the fifth one correctly instead of the other way around. But that doesn't negate the fact that this is a bug, it would just make it a much bigger bug, affecting the majority of lines wrapped by wordwrap() instead of the minority. Also note that your claim is refuted by the examples in the documentation, specifically the line "jumped over the lazy" which is 20 characters long. I urge you to look at the expected result and the actual result and consider why wordwrap() thinks "Some text" fits on one line while "Some text" doesn't, given that they both start at the beginning of a line. Previous Comments: ------------------------------------------------------------------------ [2006-06-19 15:57:50] [EMAIL PROTECTED] "wordwrap() - Returns a string with str wrapped ****AT**** the column number specified by the optional width parameter." "Some text" <- the last "t" is symbol #9, so whole "text" word is wrapped (since you didn't pass third argument). ------------------------------------------------------------------------ [2006-06-19 15:14:13] bugs dot php dot net at jonatan dot com No, I think you're the only one who is confused. ;-) I'm pretty sure this is a bug. The problem is that PHP only cuts some of the lines (the third in my example) at position 9, and incorrectly cuts some lines (the fifth in my example) at position 8. ------------------------------------------------------------------------ [2006-06-19 13:33:00] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. You may be confused with your "virtual" lines (as I was as well :). worwrap does wrap at the pos. 9 and this is what it does. Word are not cuted. ------------------------------------------------------------------------ [2006-06-19 13:09:57] [EMAIL PROTECTED] reproducible in dev branches (5.2 and head), on other OS/platform than OSX as well. ------------------------------------------------------------------------ [2006-06-19 10:55:33] bugs dot php dot net at jonatan dot com Description: ------------ wordwrap() wraps incorrectly, wrapping too early in some situations. As the example below shows, PHP wraps one of the long lines ("Some text") at the maximum line length (9 characters in this case) and wraps the other one at a shorter line length. Removing the first line from the test case results in different but equally buggy wrapping. I'm using Marc Liyanage's build of PHP, version 5.1.4 on an Intel Mac. Reproduce code: --------------- <?php $input = 'Some tex '. 'Some tex '. 'Some text '. 'Some tex '. 'Some text '. 'Some tex'; echo '<pre>'.wordwrap( $input, 9 )."</pre>\n"; ?> Expected result: ---------------- Some tex Some tex Some text Some tex Some text Some tex Actual result: -------------- Some tex Some tex Some text Some tex Some text Some tex ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37846&edit=1