On Tue, 2008-05-27 at 11:27 -0400, Robert Cummings wrote: > > You can use use an import technique to import the serialized data and > resave it in the PHP5 format: > > foo.php5 (Run via PHP5) > --------------------------------------------------------- > <?php > > class Foo > { > protected $aaa = 'aaa5'; > protected $bbb = 'bbb5'; > protected $ccc = 'ccc5'; > > static function importFromPhp4( $serialized ) > { > $array = (array)unserialize( $serialized ); > $import = new Foo(); > > $import->aaa = $array['aaa']; > $import->bbb = $array['bbb']; > $import->ccc = $array['ccc']; A loop can be used in the above assignment code to assign the properties. You just need to check if the key is prefixed by the null byte: <?php class Foo { protected $aaa = 'aaa5'; protected $bbb = 'bbb5'; protected $ccc = 'ccc5'; static function importFromPhp4( $serialized ) { $array = (array)unserialize( $serialized ); $import = new Foo(); foreach( $array as $key => $value ) { if( $key[0] !== "\x00" ) { $import->$key = $value; } } return $import; } } ?> Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php