Re: serialization: again

From: Date: Tue, 25 Jul 2000 18:45:51 +0000
Subject: Re: serialization: again
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8115@lists.php.net to get a copy of this message
The following is an example (no error checking) of taking an array and serializing it to disk, and subsequently reading it back again. // Write out an array in serialized format $filename = "array.ser"; $fp = fopen($filename, "w"); fputs($fp, serialize($some_array)); fclose($fp); // Read the array back in $fp = fopen($filename, "r"); $newarray = unserialize(fread($fp, 256000)); fclose($fp); Note, in the example I've allowed the file to be 256K in size. This is not elegant, but may or may not work in your circumstances. Thomas Baurjan Ismagulov wrote: > > hi, > > i'm trying to create a simple form designer. > > it is, basically, as follows: > * "form designer" generates form definitions in xml (btw, is there such a dtd already > available?); > * "form compiler" parses form definition files and serializes the resulting tree. > * php scripts unserialize desired form and send it to the client. > > being new to php, i've looked through the list archives. there are a lot of discussion > threads, focussed mainly on the implementability of one or other method in php. > what i'm looking for is a concrete way to implement (un)serializing. > i.e., i'm currently stucked on technical problems, that is, how do i flush the data to the > disk and how do i restore it. > > i would be very grateful if anyone could provide me with pointers in that direction. > > thanks in advance, > baurjan. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- ------------------------------------------------------------ Thomas Reinke Tel: (905) 331-2260 Director of Technology Fax: (905) 331-2504 E-Soft Inc. http://www.e-softinc.com Publishers of SecuritySpace http://www.securityspace.com

« previous php.general (#8115) next »