serialize and unserialize functions for MYSQL Storage


/ Published in: PHP
Save to your folder(s)

In a Project i had to save serialized arrays in a MYSQL Database, when i used that i got a Error Message for no reason (Error at offset XX of XX bytes in...). I wrote this little functions to fix that issue. (I dont recommend to save serialized Arrays in Databases )


Copy this code and paste it in your HTML
  1. function save_serialize($ARR) {
  2. return base64_encode(serialize($ARR));
  3. }
  4.  
  5. function save_unserialize($STR) {
  6. return unserialize(base64_decode($STR));
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.