I was porting some of my Java software over to PHP, and I noticed that PHP is still using the old C-style strtok function. It's a pain to use, because it's impossible to interleave two or more strtok's. So I decided to port Java's beautiful StringTokenizer over to PHP. The attached file is the result of this port. It supports most of the basic functionalities.
StringTokenizer class, when instantiated witha a string, breaks the string up into tokens separated by any characters specified as delimiters. Unlike the PHP strtok, you can interleave as many StringTokenizer's as you want. Each one operates independently from the others.
StringTokenizer is distributed as source code under the GNU General Public License. Please see the license agreement elsewhere on this site.
The default constructor takes a default parameter of white spaces. I noticed that I forgot to add the space character to it. This new version includes the space. Interface for the constructor has been changed to the following.
function StringTokenizer ($str, $delim = " \t\r\n")
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.
Messages, files, and images copyright by respective owners.
12 Users Online
Copyright © 1996 - 2017. All Rights Reserved.