Serialize array safely

I have issue with putting serialized array containing “‘” into database. This is how to fix it:

//to safely serialize
$safe_string_to_store = base64_encode(serialize($multidimensional_array));

//to unserialize…
$array_restored_from_db = unserialize(base64_decode($encoded_serialized_string));

Source here.

Leave a Reply