首页 > 代码库 > php数组序列化serialize与unserialize

php数组序列化serialize与unserialize

$arr=array(‘1‘,‘2‘,‘3‘);
echo serialize($arr); //序列化

a:3:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"3";}

 

$a=unserialize(a:3:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"3";}); //反序列化

dump($a);

array(3) {  [0] => string(1) "1"  [1] => string(1) "2"  [2] => string(1) "3"}

php数组序列化serialize与unserialize