From:             [EMAIL PROTECTED]
Operating system: Windows XP Home Edition
PHP version:      4.1.2
PHP Bug Type:     Feature/Change Request
Bug description:  Request new words() function returning no of words in string

I notice that PHP does not have a words() function; I propose that one is
added.

For anybody doing string processing this is an extremely useful function. 
It is a commonly found function in other languages (e.g. REXX).  It is not
just for general text processing that such a function is useful, but
whenever dealing with strings.

For example, I had a string where I had to take different actions if there
was only 1 word in a string than if there were many.  

I agree that you can do this sort of thing with regular expressions, but
hey, you can do a Leveshtein function too with regular expressions ;).

I can guarantee if there was one, it would be widely used.

words(), simply should return the number of words in a string, e.g.

words("hello") -> 1

words("this is my example") -> 4

words("     ah how about this, eh   smartass?") -> 6

words("thank you PHP team for taking the time to read this and giving due
consideration for this suggestion rather than just throwing it in the
waste bin because you've got more urgent things to do") -> 35

Hugh Prior
-- 
Edit bug report at http://bugs.php.net/?id=16681&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=16681&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=16681&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=16681&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16681&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16681&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16681&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=16681&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=16681&r=submittedtwice

Reply via email to