下方陣列轉字串,字串再轉回陣列,下方提供範例下載
<?php
$arr = array(
'aa'=>'aa',
'bb'=>'bb',
'cc'=>'cc',
'arr'=>array(1,2,3)
);
$str = serialize($arr);
echo $str;
echo '<br/>===<br/>';
$rearr = unserialize($str);
var_dump($rearr);
output
a:4:{s:2:"aa";s:2:"aa";s:2:"bb";s:2:"bb";s:2:"cc";s:2:"cc";s:3:"arr";a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}}
===
array(4) { ["aa"]=> string(2) "aa" ["bb"]=> string(2) "bb" ["cc"]=> string(2) "cc" ["arr"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } }
範例:
download