1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| function explode(inputstring, separators, includeEmpties) {
inputstring = new String(inputstring);
separators = new String(separators);
if(separators == "undefined") {
separators = " :;";
}
fixedExplode = new Array(1);
currentElement = "";
count = 0;
for(x=0; x < inputstring.length; x++) {
char = inputstring.charAt(x);
if(separators.indexOf(char) != -1) {
if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) { }
else {
fixedExplode[count] = currentElement;
count++;
currentElement = ""; } }
else { currentElement += char; }
}
if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {
fixedExplode[count] = currentElement; }
return fixedExplode;
} |
Partager