View Single Post
Old Aug 4th, 2006, 10:27 PM   #1
cCj
Newbie
 
Join Date: Mar 2006
Posts: 11
Rep Power: 0 cCj is on a distinguished road
How to save the array vars in a class?

Hi,
I'm using serialize to save an object which worked until I started using Arrays in the class. Please see this code below:

class Base extends Tile
{
 var $owner;
 var $resources = Array();
 
 function Base($owner)
 {
	$this->Tile();
	$this->owner = $owner;
 }
 function __sleep()
 {
   // used this before which works for simple vars like owner
    //return array('owner');
   // trying this now but doesn't seem to work for arrays
	return( array_keys( get_object_vars( &$this ) ) );
 }
}

Then you would just call serialize and unserialize.

But like I commented that doesn't work, the array is not saved.
Any suggestions what could I try?

Thanks.
cCj is offline   Reply With Quote