Greetings…
I managed to load the double dimension array with a string, but I’m not very happy with the coding. Perhaps someone can tell me how to apply this a better way?
Below is the code I’m using.
<SCRIPT LANGUAGE=”JavaScript”>
var myString = “0~1~2~3~4|1~5~6~7~8|2~9~0~1~2|3~3~4~5~6”;
var myTempArray = myString.split(“|”);
//Write out the array values from the first split.
for (i=0; i < myTempArray.length; i++) {
document.write(“<br>myTempArray[” + i + “] = ” + myTempArray[i] );
}
//Create a new array which contains the double dimension array.
document.write(“<br>”);
var myNewArray = new Array();
for (j=0; j < myTempArray.length; j++) {
var myNewArray2 = myTempArray[j].split(“~”);
myNewArray[j] = new Array();
for (k=0; k < myNewArray2.length; k++) {
myNewArray[j][k] = myNewArray2[k];
}
}
for (a=0;a<myNewArray.length;a++){ //myNewArray is the array that we’ve already created earlier
for (b=0;b<myNewArray[a].length;b++){
document.write(“<br>myNewArray[” + a + “][” + b + “] = ” + myNewArray[a][b]);
}
}
</script>