note 42817 added to function.strtok

From: Date: Sun, 30 May 2004 19:41:51 +0000
Subject: note 42817 added to function.strtok
Groups: php.notes 
Request: Send a blank email to php-notes+get-70316@lists.php.net to get a copy of this message
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) { // ... } ?> ---- Manual Page -- http://www.php.net/manual/en/function.strtok.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42817 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42817&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42817&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70316) next »