Re: strtok bug

From: Date: Wed, 04 Oct 2000 01:49:08 +0000
Subject: Re: strtok bug
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18580@lists.php.net to get a copy of this message
Hi, I figured what was happening: when "hello, world" is tokened, after the "," is a null word which causes the while to stop. is there a way to find out if is the end of the string (something like "hasNext ?") ? ----- Original Message ----- From: "Florin Sanda" <florin@proweb.ro> To: <php-general@lists.php.net> Sent: Wednesday, October 04, 2000 3:37 AM Subject: [PHP] strtok bug Hi, strtok() function has a little bug (it's not working like in Java anyway) here is an example to see what I mean: <? $string="hello,world"; $tok=strtok($string," ,"); while($tok) { echo "$tok@"; $tok=strtok(" ,"); } ?> the output is "hello@world@" which is fine, but when $string="hello, world" (multiple seperators one after each other) the output is just "hello@" !!! Is this a PHP version problem? Florin Sanda PRO Web Solutions http://www.proweb.ro

« previous php.general (#18580) next »