I have an update... a year later. There is something wrong with the explode() function currently in the first post. I can't remember exactly what it is, but the output is incorrect for certain situations. The following version should fix those problems:
PHP Code:
public function explode(delimiter, string, limit) {
temp.tokens = temp.string.tokenize(temp.delimiter);
if(!temp.delimiter || temp.delimiter == "") {
return false;
}
if(!temp.limit || temp.limit == 0) {
return temp.string.tokenize(temp.delimiter);
}
if(temp.limit > temp.tokens.size()) {
temp.limit = temp.tokens.size();
}
if(temp.limit > 0) {
for(temp.i = 0; temp.i <= temp.limit - 1; temp.i ++) {
temp.output.add(temp.tokens[temp.i]);
}
for(temp.i = 0; temp.i < temp.tokens.size() - temp.limit; temp.i ++) {
temp.output[temp.limit - 1] @= temp.delimiter @ temp.tokens[temp.limit + temp.i];
}
}
else {
temp.limit *= -1;
for(temp.i = 0; temp.i <= temp.limit - 1; temp.i ++) {
temp.output.add(temp.tokens[temp.i]);
}
}
return temp.output;
}