Jump to content

cCj

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cCj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you Barand, your code works just like mine and I was able to find the problem now that I knew the problem was not in the serialazation. What I was doing was something like this: [code] $tile = $map[$y][$x]; $tile->addToUnits($unit); [/code] When the working code was: [code] $map[$y][$x]->addToUnits($unit); [/code] So I had misunderstood how php handles variables, even $map had objects the assigment to $tile actually copied the object instead of passing reference to it. So I will be using & to get the reference instead of copy from now on. Thanks.
  2. [quote author=poirot link=topic=103711.msg413179#msg413179 date=1155216728] What do you mean with "the array is not saved"? [/quote] It's empty once unserialized. The owner var however has it's value so I was thinking that it was "not saved".
  3. Hi, I'm using serialize to save an object which worked until I started using Arrays in the class. Please see this code below: [code]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 ) ) ); } }[/code] 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.
×
×
  • 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.