CodeIgniter Forums
serialize or convert array to strings? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: serialize or convert array to strings? (/showthread.php?tid=40922)



serialize or convert array to strings? - El Forum - 04-22-2011

[eluser]carvingCode[/eluser]
I'm curious what the thought is on storing array contents to the database?

I've most always converted the array to a string, stored it to the db, and then did the reverse on the way out. Have recently started using 'serialize/unserialize' to do the same.

Using these functions means a lot less overhead, in terms of code I need to maintain. But, my newness to using these functions has me curious if there's any drawbacks I need to know about?

TIA

Randy


serialize or convert array to strings? - El Forum - 04-22-2011

[eluser]danmontgomery[/eluser]
That's exactly what those functions are intended for, converting an array/object to a string.


serialize or convert array to strings? - El Forum - 04-22-2011

[eluser]Victor Michnowicz[/eluser]
Also have a look at json_encode. It may be faster.