# Pass a string to the index of an array

**URL:** <https://forum.kirupa.com/t/pass-a-string-to-the-index-of-an-array/138100>\
**Category:** Uncategorized\
**Created:** [February 19, 2005, 11:39pm UTC](https://forum.kirupa.com/t/pass-a-string-to-the-index-of-an-array/138100 "2005-02-19T23:39:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackpulp](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blackpulp/32/81_2.png) [@blackpulp](https://forum.kirupa.com/u/blackpulp)\
**Post date:** [February 19, 2005, 11:39pm UTC](https://forum.kirupa.com/t/pass-a-string-to-the-index-of-an-array/138100/1 "2005-02-19T23:39:11Z")

</div>

ok, i have a complex array that i have built out of the results from a database, and i am using strings to index the array instead of numerical values…

for example, i am indexing my array like this:

```auto
my_array["news"] = new Array();
my_array["news"][0] = "first news post";
my_array["news"][1] = "first news post";
my_array["news"][2] = "first news post";

```

etc…

so then, i want to basically call that array dynamically by feeding a variable into the index, like this:

```auto
ind = "news";
l = my_array[ind].length;
trace(l);

```

now when i do that, its not finding the array’s length, and i know this because my trace prints nothing, or undefined…so this tells me i can’t pass the string to the index of the array? how do i do this? there has to be a way??? i hope this question makes sense…i am desperate need of help here
