We help IT Professionals succeed at work.

# Arrrays problem

on
Medium Priority
157 Views
i have this code, bacausally i have a big array of items and i want to seperate it down into an array or arrays so instead of having an array with 97 items i would have an array with 5 items each is an array with a max of 20 items

index 0 - 20 items (0- 19)
index 1 - 20 items (19 - 40)
index 2 - 20 items (41 - 60)
index 3 - 20 items (61 - 80)
index 4 - 20 items (81 - 97)

this code works if i just put a simlpe value in ie

seperateItemsArray[itemIndex][h]= i  ;

but if i try to put in a array

seperateItemsArray[itemIndex][h]= details[i]  ;

it just goes blank

help

``````var itemsArray:Array = new Array();

var seperateItemsArray:Array = new Array();
var itemIndex:Number= 0;
var h=0;

seperateItemsArray[itemIndex] = new Array();

for(var i:Number = 0 ; i < details.length ; i++)
{

if(h < 20)
{
//seperateItemsArray[itemIndex][h] = new Array();

seperateItemsArray[itemIndex][h]= details[i]  ;

h++;
}
else
{
h = 0;
itemIndex++;
seperateItemsArray[itemIndex] = new Array();
}
}
``````
Comment
Watch Question

## View Solution Only

Engineering Manager / Architect
CERTIFIED EXPERT
Commented:

<code snippet>

Good Luck
-V
``````var fullArray:Array = new Array();
var splittedArray:Array = new Array();

for(i=0;i<=96;i++) {
fullArray[i] = i+1;
}

splitArray(fullArray);

function splitArray(temp:Array):Void {
count = 0;
arrNum = 0;
var tempArray:Array = new Array();
for(i=0;i<=fullArray.length-1;i++) {
tempArray[count] = fullArray[i];
if(count<20) {
count++;
} else {
splittedArray[arrNum] = tempArray;
var tempArray:Array = new Array();
count = 0;
arrNum++;
}
}
splittedArray[arrNum] = tempArray;
}

trace("Array 1: " + splittedArray[0]);
trace("Array 2: " + splittedArray[1]);
trace("Array 3: " + splittedArray[2]);
trace("Array 4: " + splittedArray[3]);
trace("Array 5: " + splittedArray[4]);
``````

Commented:
Great thanks this got me out of a bind, thanks for the quick reply