Page 1 of 1

Gettoken count counts one more?

Posted: 06 Oct 2012 18:08
by Marco

Code: Select all

echo gettoken("a,b,c,d,e", "count", ","); // 5
But I see only four commas...

Re: Gettoken count counts one more?

Posted: 06 Oct 2012 18:15
by serendipity
Marco wrote:

Code: Select all

echo gettoken("a,b,c,d,e", "count", ","); // 5
But I see only four commas...
Yes, i was confused too when Don first introduced this, but its to get all 5 tokens; a thru e.
edit: token 1 would be a and token 5 would be e, commas are separators not tokens itself.

Re: Gettoken count counts one more?

Posted: 06 Oct 2012 18:19
by Marco
serendipity wrote:Yes, i was confused too when Don first introduced this, but its to get all 5 tokens; a thru e.
edit: token 1 would be a and tone 5 would be e, commas are separators not tokens itself.
So in this case is a count of tokens and not a count of separators, right? Ok, now makes sense.