Bug #16681 Updated: Request new words(), word(), wordindex(), wordlength() functions]

From: Date: Fri, 19 Apr 2002 10:08:32 +0000
Subject: Bug #16681 Updated: Request new words(), word(), wordindex(), wordlength() functions]
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1203@lists.php.net to get a copy of this message
Hi, In case you didn't follow PHP-Dev, here's the request from an user: ------------------------------------------------------------------------ [2002-04-19 04:22:01] phpbugs@priorwebsites.com I wish to expand this request to suggest full support for word processing in strings. This is something which is extremely useful (it appears for example in REXX) when processing strings. word (str, num) Returns the num'th word from string str. If num is greater than the number of words in str, the null string is returned. wordindex (str, num) Returns the character position of the first letter of the num'th word in string str, or 0 if num is greater than the number of characters in str. wordlength (str, num) Returns the length of the num'th word in string str, or 0 if num is greater than the number of words in str. words (str, num) Returns the number of words in the string str. ------------------------------------------------------------------------ I know it's terribly easy to do (1-2 liners), but I'd like to contribute to PEAR and learn about the coding-rules. there are just some questions left: - am I allowed to use ternary operators "?" and ":" ? - am I allowed to jump out of a switch without using break? Example: function foo($bar) { switch($bar) { case 'moo': return 'cow'; case 'woof': return 'dog'; } return false; } - Is PEAR about creating stuff people should learn from? I mean perfect, "educational" code or am I allowed to to used advanced techniques? I'm making excessive use of regular expressions. - why should I write curly braces like this: function foo() { } instead of function foo() { } Blocks start with a keyword, such as for, while, function and end with a "}". I find this perfectly esthetical. - why do function names use "bumpy case" instead of C-like or even PHP-like "underscored" function names? -daniel ----- Original Message ----- From : Daniel Lorch [mailto:daniel@lorch.cc] Sent : Freitag, 19. April 2002 Subject: [PEAR] Re[2]: [PHP-DEV] [phpbugs@priorwebsites.com: Bug #16681 Updated: Request new words(), word(), wordindex(), wordlength() functions] > Hi, > Great idea. I could take care of this - how do I "assign" it to me? > Just start writing code? > -daniel > ----- Original Message ----- > From : derick@php.net [mailto:derick@php.net] > Sent : Freitag, 19. April 2002 > Subject: [PHP-DEV] [phpbugs@priorwebsites.com: Bug #16681 Updated: Request new words(), word(), > wordindex(), wordlength() functions] >> Hey, >> why not make a PEAR thingy for this? >> Derick >> On Fri, 19 Apr 2002, Daniel Lorch wrote: >>> hi, >>> >>> > Well, I like the idea(s). >>> >>> > I think returning (bool)false instead of NULL is more >>> > consistent though. >>> >>> > Maybe the naming convention should be changed to: >>> >>> ..while paying attention to english orthography: >>> >>> > word() >>> > word_count() >>> > word_index() >>> > word_lenght() >>> >>> word_length() >>> >>> common pitfall - maybe we should provide an alias? :) >>> >>> > - Markus >>> >>> word_* functions can be easily solved in userland, but nevertheless, >>> after thinking about it, it might be a good addition. At least it does >>> not hurt anyone, does it? :) >>> >>> -daniel >>> >>> >>> >>> -- >>> PHP Development Mailing List <l4”0¨ó >>> ªH•Q»oðhttp://www.php.net/> >>> To unsubscribe, visit: http://www.php.net/unsub.php >>>

« previous php.pear.general (#1203) next »