Skip to main content

php store array in database ?

By October 31, 2011My SQL
Array can be stored in database in the form of string.we can use serialize function to make storable representation of array.we can also get back from that string to array using unserialize

$arr=array(“India”,”Pakistan”,”Sri Lanka”,”Bangladesh”);
//process of serialization
//it will produce following output
a:4:{i:0;s:5:”India”;i:1;s:8:”Pakistan”;i:2;s:9:”Sri Lanka”;i:3;s:10:”Bangladesh”;}
//process of unserialization

//it will produce following output
Array ( [0] => India [1] => Pakistan [2] => Sri Lanka [3] => Bangladesh )