# \[FMX\] variable name problem

**URL:** https://forum.kirupa.com/t/fmx-variable-name-problem/126320
**Category:** Uncategorized
**Created:** [October 22, 2004, 3:17am UTC](https://forum.kirupa.com/t/fmx-variable-name-problem/126320 "2004-10-22T03:17:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gigital](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gigital/32/833_2.png) [@gigital](https://forum.kirupa.com/u/gigital)
#### Post date: [October 22, 2004, 3:17am UTC](https://forum.kirupa.com/t/fmx-variable-name-problem/126320/1 "2004-10-22T03:17:02Z")

</div>

Here’s what I need…

a for loop that iterates through an array, and for each item in the array, creates a new variable…

```php

someObject = new Object();
for (i=0;i<theArray.length;i++){
	 // here's where i need help...
	 someObject.newProperty_i = theArray*;
}

```

basically, after the loop completes I want someObject to have newProperty\_0, newProperty\_1, … newProperty\_i. I’ve tried using addProperty(), but I’m not quite clever enough to figure out what to make the getFunction.

```php

for (i=0;i<theArray.length;i++){
	theGetFunction = new Function(){
		 return theArray*;
};
someObject.addProperty("newProperty_"+i, theGetFunction, null);
// valid code to make a new property (read-only)
// unfortunately, it doesn't perform the way I want it to
}

```

As I said, it is valid code, but as it stands, all the newProperty\_ variables all output whatever theArray\* is (after the loop has executed), instead of outputting what theArray\* WAS when I attached the property…

I’ve been banging my head against the wall here. I know there’s someone out there with a simple and elegant solution. HELP!
