I have this object:
foreach(range(1,$oc->num_users) as $num) {
$user = 'user' . $num;
$$user = mysql_fetch_object(mysql_query("SELECT user".$num.", user".$num."_ready, FROM oc_db WHERE leader='".$_SESSION['username']."' "));
This gives objects named user1..X
later I have a simular function like this, where I use the $$user->$user that represent a username to connect to the db to get additional information.
$$user = mysql_fetch_object(mysql_query("SELECT x, y, z FROM user_db WHERE username='".$$user->$user."' "));
This also makes objects named user1..X, but instead of replacing the object created earlier I want to append this values to the object I created in the first function. $$user is the name of the objects. I would like to do something like $$user .= fetch_object in the last function, but off course it’s not that simple.
In order to append one object to another you simply need to iterate through the first object and then assign each property you find to the second one: