[英]PHP: Sort cookies alphabetically?
I've created a shopping cart where the products are stored in cookies, and I display all the cookies using this loop: 我创建了一个购物车,其中产品存储在cookie中,并使用以下循环显示所有cookie:
foreach($_COOKIE['products'] as $productId => $productQuantity) {
The problem is, every time add 1 to the quantity (so when I change the cookie value), that cookie ends up last in the list of the cart's products. 问题是,每次向数量添加1(因此,当我更改cookie值时),该cookie最终出现在购物车产品列表中。 How can I sort these cookies alphabetically, so the order will always be the same? 我如何按字母顺序对这些cookie进行排序,所以顺序将始终相同?
Many thanks! 非常感谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.