我有一些模块创建了定制购物车。
当我将产品添加到 cart的购物车数据库内容时,是:
a:3:{
s:8:"products";
a:7:{
i:10;
a:3:{
s:10:"product_id";
i:10; <- product id
s:6:"amount";
i:2; <- amount of product
s:5:"price";
s:6:"1.2500"; <- product price
}
i:11;
a:3:{
s:10:"product_id";
i:11;
s:6:"amount";
i:9;
s:5:"price";
s:7:"1.2500";
}
}
s:3:"sum";
d:2.5000; <- this is total sum of cart
s:6:"amount";
i:49; <- this is total amount of products
}
我想要创建PHP脚本,它从上面的代码中解析细节。我需要从每个a:3:{ .}中获取内容,并在表视图中显示产品id、数量、价格
我在php解析方面完全是新手,不知道从哪里开始。已经看过一些手册,但还远远没有完成任务。有人能帮忙吗?
发布于 2016-09-30 05:46:53
您的数据库内容看起来像序列化的数组。对此序列化数据使用非序列化来正确地访问它:
为了显示表中的内容,使用PHP的数组访问机制。这里有更多信息:
https://stackoverflow.com/questions/39792816
复制相似问题