PHP :: Bug #35427 :: str_word_count() handles '-' incorrectly
| Bug #35427 | str_word_count() handles '-' incorrectly | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2005-11-27 19:12 UTC | Modified: | 2005-11-29 17:14 UTC |
|
||||||||||
| From: | tomas_matousek at hotmail dot com | Assigned: | iliaa (profile) | |||||||||||
| Status: | Closed | Package: | Strings related | |||||||||||
| PHP Version: | 5.1.0 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2005-11-27 19:12 UTC] tomas_matousek at hotmail dot com
Description:
------------
Characters specified in str_word_count() should be treated equally to letters, right?
This works for apostrophe but doesn't for hyphen.
Reproduce code:
---------------
var_dump(str_word_count("foo'0 bar-0var", 2, "0"));
Expected result:
----------------
array(3) {
[0]=>
string(5) "foo'0"
[6]=>
string(3) "bar0var"
}
Actual result:
--------------
array(3) {
[0]=>
string(5) "foo'0"
[6]=>
string(3) "bar"
[10]=>
string(4) "0var"
}
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2005-11-27 19:28 UTC] tony2001@php.net
[2005-11-27 20:00 UTC] tomas_matousek at hotmail dot com
[2005-11-28 21:27 UTC] tomas_matousek at hotmail dot com
No, I needn't. str_word_count("bar-var") returns 1, so '-' is considered as a part of the word if it is followed by 'word' character. See the source code. The bug is clear there.[2005-11-29 09:41 UTC] tomas_matousek at hotmail dot com
[2005-11-29 09:45 UTC] tomas_matousek at hotmail dot com
[2005-11-29 17:14 UTC] iliaa@php.net