Forum Moderators: coopster

Message Too Old, No Replies

add a string with a variable name?

         

Polish Renegade

7:36 pm on Aug 10, 2006 (gmt 0)

10+ Year Member



I am wondering if there is a way to take a variable

-ex. $item

Add a string to it

- $item."1"

and retreive it as

- $item1

The equivalent in Action Script is
- var items["#*$!"]

Thanks.

maherphil

9:15 pm on Aug 10, 2006 (gmt 0)

10+ Year Member



in an array you could do something like

$myArray[$count]{$item."$num"}

where $num is a counter as well.

the result would look something like this:

$myArray[0][myItemName0]

Polish Renegade

5:13 am on Aug 11, 2006 (gmt 0)

10+ Year Member



Thanks but its not an array...

Is there anyway to do it without having to use an array?

maherphil

2:18 pm on Aug 11, 2006 (gmt 0)

10+ Year Member



try

$newVar = $item.$num;

coopster

1:04 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Polish Renegade.

The equivalent in Action Script is
- var items["#*$!"]

This is an array in ActionScript, too. PHP arrays operate the same way. Another neat feature in PHP is what we call variable variables [php.net]. Perhaps that is something you can use?