note 77148 added to function.serialize
| From: | nothanks at nothanks dot no | Date: | Thu, 16 Aug 2007 22:02:24 +0000 |
| Subject: | note 77148 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129546@lists.php.net to get a copy of this message | ||
I had to put a massive multidimensional array in a single field in the database. Unfortunatly the
array contained lots of "forbidden" characters: ", ', ;, :, and so on and so
forth, breaking the query and my later attempts at deserialize().
Here's a quick and dirty solution:
<?php
$safe_string_to_store = base64_encode( serialize( $multidimensional_array ) ) ;
?>
And in the other end:
<?php
$encoded_serialized_string = dbh->query("SELECT archives_arr FROM ". $table_name .
" WHERE id=0")
$array_restored_from_db = unserialize( base64_decode( $encoded_serialized_string ));
?>
----
Server IP: 129.16.214.50
Probable Submitter: 83.251.203.23
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- https://master.php.net/note/edit/77148
Del: integrated -- https://master.php.net/note/delete/77148/integrated
Del: useless -- https://master.php.net/note/delete/77148/useless
Del: bad code -- https://master.php.net/note/delete/77148/bad+code
Del: spam -- https://master.php.net/note/delete/77148/spam
Del: non-english -- https://master.php.net/note/delete/77148/non-english
Del: in docs -- https://master.php.net/note/delete/77148/in+docs
Del: other reasons-- https://master.php.net/note/delete/77148
Reject -- https://master.php.net/note/reject/77148
Search -- https://master.php.net/manage/user-notes.php