# How to populate a vector using an existing array?

**URL:** <https://forum.kirupa.com/t/how-to-populate-a-vector-using-an-existing-array/315160>\
**Category:** flash\
**Created:** [October 19, 2010, 9:34am UTC](https://forum.kirupa.com/t/how-to-populate-a-vector-using-an-existing-array/315160 "2010-10-19T09:34:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayumilove](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ayumilove/32/2532_2.png) [@ayumilove](https://forum.kirupa.com/u/ayumilove)\
**Post date:** [October 19, 2010, 9:34am UTC](https://forum.kirupa.com/t/how-to-populate-a-vector-using-an-existing-array/315160/1 "2010-10-19T09:34:21Z")

</div>

Below is a method to populate a vector with a list of strings

```php

var vector:Vector.<String> = new <String>["abc","def"];

```

However, I have an existing array that contains a list of strings.  
How would I transfer those contents within the array into the vector?

The basic way I can think of is using a for loop, and push the values in.

```php

var array:Array = ["1,2,3","4,5,6"];
var vector:Vector.<String> = new <String>[];

for (var i:int = 0; i< array.length; i++)
{
	vector.push(array*);
}
trace(vector[0]); //traces 1,2,3

```

Are there any other alternatives?
