note 47809 deleted from function.serialize by aharvey

From: Date: Tue, 06 Nov 2012 02:06:29 +0000
Subject: note 47809 deleted from function.serialize by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191753@lists.php.net to get a copy of this message
Note Submitter: ---- This is just a modification of what Alan Reddan (areddan at silverarm dot ie) posted below. I figured it would be faster than walking an array, and it works wonderfully with cookies <?php $data[qwerty] = "blah"; $data[1][a] = "1aa"; $data[2][b] = "2bb"; $data[3][c] = ";;;;;;"; $data[name][first] = "Bob"; $data[name][last] = "Jones"; $data[val] = "This is a real long test string, to see how well the compression works!"; //To Serialise Call : $string = gzcompress(serialize($data), 9); setcookie("my_var", $string, time()+60*60*24*60, '/'); //print "String: $string\n<br>"; //uncomment to see serialized array //To Unserialize Call if (isset($_COOKIE[my_var])) { $array = unserialize(gzuncompress($_COOKIE[my_var])); echo "<pre>"; print_r($array); echo "</pre>"; } ?> you can replace gzcompress with base64_encode and gzuncompress with base64_decode to have a similar experience Alan, thanks for the tip though, it got me where I wanted to be!

« previous php.notes (#191753) next »