在饼干PHP数组 [英] Arrays in cookies PHP
本文介绍了在饼干PHP数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何是存储在cookie中的数组有道?在PHP
code例如:
$ number_ticket = 2;
$信息[7] [5] = 1;
$信息[8] [5] = 1;
解决方案
序列化数据:
的setcookie('饼干',序列化($资讯),时间()+ 3600);
然后反序列化数据:
$数据=反序列化($ _ COOKIE ['饼干']);
在数据,信息$ $和数据将具有相同的内容。
How is proper way to store an array in a cookie? in PHP Code example:
$number_ticket=2;
$info[7][5]=1;
$info[8][5]=1;
解决方案
Serialize data:
setcookie('cookie', serialize($info), time()+3600);
Then unserialize data:
$data = unserialize($_COOKIE['cookie']);
After data, $info and $data will have the same content.
这篇关于在饼干PHP数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文