note 77148 deleted from function.serialize by aharvey
| From: | aharvey@php.net | Date: | Tue, 06 Nov 2012 02:11:55 +0000 |
| Subject: | note 77148 deleted from function.serialize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191778@lists.php.net to get a copy of this message | ||
Note Submitter: nothanks at nothanks dot no
----
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 ));
?>