Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户选择一个项目时,我必须将一组唯一项目存储到 $_SESSION。每个项目没有唯一的 ID,我使用 itemName 和 storeID 的组合。将每个元组(或类似的对象/固定数组)存储到 Session 中的数组的合适方法是什么?
我会让 foreach 存储一个数组,其中包含该商店中所有选定的项目。例如:
$_SESSION['items'] = array( "store1" => array("item1", "item2",...), "store2" => array("item1", "item2",...), ... );