Jump to content

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

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.