Cynosure.X International LLC


Add Comment | Related Links | TrackBack
Related Content

StringTokenizer.php (GPL)

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.


class StringTokenizer
function StringTokenizer ($str, $delim = "\t\r\n")

function countTokens ()

function hasMoreTokens ()

function nextToken ()

Attached File: StringTokenizer.txt (750 B)

Chieh Cheng
Wed, 25 Jul 2007 17:49:17 +0000

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")

Attached File: 1 - StringTokenizer.txt (783 B)

Chieh Cheng
Sun, 02 Dec 2007 06:45:18 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 8 + 10?
Click button only once, please!


TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

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.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

46 Users Online

Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.