note 42817 deleted from function.strtok by nlopess

From: Date: Sun, 08 May 2005 07:50:21 +0000
Subject: note 42817 deleted from function.strtok by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89107@lists.php.net to get a copy of this message
Note Submitter: bishop ---- Do not blindly follow the first example in the documentation. Consider: <?php // three tokens to separate $part = strtok('1:0:2', ':'); while ($part) { $part = strtok(':'); } ?> This loop will only execute ONCE, not three times. This happens because $part === 0 on the second pass, which ends the while loop. You want this, instead: <?php // ... while ($part !== false) { // ... } ?>

« previous php.notes (#89107) next »