Re: [PHP-DEV] CVS update: php3/functions From: Rasmus Lerdorf (rasmus <email protected>)
Date: 09/30/98

> Fix for bug #800

I don't agree with this fix. You have just made strtok() completely
non-standard. strtok() has never ignored multiple adjacent tokens, and I
don't think it should. The C equivalent function certainly doesn't do
this.

If you have:

  $a="a b";

And you tokenize on " " (a space) then you should get:

 "a"
 ""
 "b"

when you go through the string. Bug report #800 is bogus because the
loops relies on the result of the strtok() to be true in order for it to
continue. If you have two adjacent tokens then you are correctly going to
get a null string as the strtok() result.

If someone doesn't want this behaviour, then they should compact their
string before running strtok on it. Something like:

  $new = ereg_replace(" +"," ",$string);

Chances are the user should be using explode() anyway though.

-Rasmus

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>