Hi

My problem is actually in an ActionScript3 system, but I think the concept is the same.

I am creating instances of an object repeatedly, and I want to give each new instance a unique name. As the loop runs, it calls a function which creates a new instance.

Currently, I am passing a 'counter' number to the 'Create new instance function' to use in naming the new instance, but Im stuck taking a variable and making a new variable(the new instance) using the value of the passed variable, as its name...?

Help!

I think this is what you are talking about:

function create( &$var ) {
    $var = new $var;
}

to use define a variable and then call the function

$class = 'class_name';
create( $class );
echo $class->testing;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.