Jump to content

[SOLVED] Automatic creation of vars from an object


flaab

Recommended Posts

Hi everyone =)

 

I'll go straight to the problem. I want to copy the vars from an object to normal variables with the same name as its attributes, whatever the object is and outside of it.

 

Suppose we have an object like this:

 

Object Foo
     var $var1 = Whatever1
     var $var2 = Whatever2
     var $var3 = Whatever3
     var $var4 = Whatever4
End object

 

And i want to create normal global variables from it like this...

$var1 = Whatever1
$var2 = Whatever2
$var3 = Whatever3
$var4 = Whatvere4

 

I've tried the following but it doesn' t work:

foreach($objet as $key => $value)
{
$key = $value;
}

 

How can i do that? It has to work for any object with it's attributes public

 

Thnaks in advanced

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.