php store array in database ?

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 function.eg.

<?php
$arr=array("India","Pakistan","Sri Lanka","Bangladesh");
//process of serialization
$newString=serialize($arr);
//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
$arr=unserialize($newString);
print_r($arr);

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

?>

Most Popular

The difference between React vs AngularJs

Enabling Gzip Compression of PHP, CSS, and JS Files Without mod_deflate