Re: strtok buggy ?

From: Date: Wed, 28 Jun 2000 12:35:46 +0000
Subject: Re: strtok buggy ?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-22620@lists.php.net to get a copy of this message
I?d suppose using while($tok!==FALSE); or even shorter $str='test-test2-test3-0-sadf'; $tok=strtok ($str,"-"); while (($tok=strtok ("-"))!==FALSE) echo "->$tok<BR>\n"; regards That?s the fastest possibility. regards Stanislav Malyshev wrote:
CS>>     It seem that strtok trouble with the 0 string. Try this little
CS>> script : CS>>
CS>>     $str = "ta-mere-en-0-short";
CS>>     $tok = strtok ($str,"-");
CS>>     while ($tok)
No, there's trouble with your while. "0" has false value when converted to boolean. Use != "" or something like that.
-- o----------0-?---------O-?---?----o---?-----o o O ? . | http://www.kiffen.de | pRotec,t y0ur bRai'n |0 O ? ? ? ? 0??^(3)?^(2)'^(2)^(3)-^(1)'^(3)?^(3)?^?^(3)~^(3)^(2)^(3)?'^(3)^(2)^(2)?^(3)^(2)^^(3)^(1)^(3)^(2)?^(2)^(3)`^(3)^(o)^(3)?? ? o (c) ? . ? | psychedelic experience | gott@kiffen.de | O ? o ? o-?--o--0-----(c)-?--O-----o-----0-?----------o 0 ? ? ? . ? ?

« previous php.dev (#22620) next »