risultato:codice:Array.prototype.find = function(val, pos) { pos = pos == undefined ? 0 : pos; for (i=0; i<this.length; i++) { if (this[i] instanceof Array) { if (this[i][pos] == val) { return i; } } else { if (this[i] == val) { return i; } } } }; referList = "Uno|Uno|Due|Tre|Quattro|Cinque|Tre|Tre|Otto|Nove|"; referLista = new Array(); franco = new Array(); referLista = referList.split('|'); for (t=0; t<(referLista.length-1); t++) { i = franco.find(referLista[t]); if (i != undefined) { franco[i][1]++; } else { franco.push([referLista[t], 1]); } } trace(franco);
Uno,2,Due,1,Tre,3,Quattro,1,Cinque,1,Otto,1,Nove,1

Rispondi quotando