Is there a tokenizer function (similar in nature to Java's) where you can parse a string based on a non-space delimter... for instance:
if you have the string "0001;4;hello"
You could parse based on the semicolon into 3 tokens... "0001", "4", and "hello"? If so, how?
THanks,
Trey
PHP Tokenizer?
Moderator: General Moderators
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
I found it...
That will do it.
Code: Select all
$tok = strtok($theString, ";");- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
I understand that strtok is the most similar to Java's, but it has some problems (notably the fact that there's only one stack). I prefer tokenizing my strings all at once:
Code: Select all
$string = '0001;4;hello';
$array = explode(';', $string);
foreach ($array as $value) {
// do stuff
}