note 114349 added to function.strtok

From: Date: Tue, 11 Feb 2014 17:12:26 +0000
Subject: note 114349 added to function.strtok
Groups: php.notes 
Request: Send a blank email to php-notes+get-198458@lists.php.net to get a copy of this message
Might be pointing out the obvious but if you'd rather use a for loop rather than a while (to keep the token strings on the same line for readability for example), it can be done. Added bonus, it doesn't put a $tok variable outside the loop itself either. Downside however is that you're not able to manually free up the memory used using the technique mentioned by elarlang. <?php for($tok = strtok($str, ' _-.'); $tok!==false; $tok = strtok(' _-.')) { echo "$tok </br>"; } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/function.strtok.php Edit -- https://master.php.net/note/edit/114349 Del: integrated -- https://master.php.net/note/delete/114349/integrated Del: useless -- https://master.php.net/note/delete/114349/useless Del: bad code -- https://master.php.net/note/delete/114349/bad+code Del: spam -- https://master.php.net/note/delete/114349/spam Del: non-english -- https://master.php.net/note/delete/114349/non-english Del: in docs -- https://master.php.net/note/delete/114349/in+docs Del: other reasons-- https://master.php.net/note/delete/114349 Reject -- https://master.php.net/note/reject/114349 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198458) next »