Well, the obvious:
Code:
var s = "id1,name1,id2,name2,id3,name3...."
var temp = s.split(",");
var element = [ ];
for ( var t = 0, e = 0; t < temp.length; t += 2, ++e )
{
element[e] = [ temp[t], temp[t+1] ];
}
But we could probably get sneakier....
Code:
var s = "id1,name1,id2,name2,id3,name3...."
var temp = s.replace( /([^\,]+\,[^\,]+)\,/g, "$1;" ).split(";");
var element = [];
for ( var t = 0; t < temp.length; ++t )
{
element[t] = temp[t].split(",");
}
Mildly sneaky. Works so long as none of the substrings contain semicolons.
Seems hardly worth trouble. I'd just use version 1.