我们可以使用 PHP SESSION 数组来做到这一点吗?
您好,我们可以使用 php 会话创建二维数组吗?如果可能的话如何随机取消设置值。
Hi can we create two dimensional array using php session. If possible how to unset values randomly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,PHP 不实现多维数组。然而,数组的元素可以是数组本身。并且任何 PHP 数据项都可以存储在会话中(但是,资源在它们初始化所在的线程之外变得毫无意义,并且对象需要从会话中引用类定义)。
例如
这在二维数组中是一个矛盾的说法。但在数组数组的上下文中是完全有效的:
No, PHP does not implement multi-dimensional arrays. However an element of an array can be an array itself. And any PHP data item can be stored in the session (however resources become meaningless outisde the thread they were initialized in, and objects require class definitions to be referenced from the session).
e.g.
This would be an oxymoron in a 2-dimensional array. But is perfectly valid in the context of an array of arrays:
瞧,会话中的二维数组。
脚本执行时,会话变量没有任何特殊之处。它们唯一的“魔力”是它们在 session_start() 处反序列化并在 session_close() 处序列化
Voila, a two-dimensional array, in a session.
The session variables are in no way special while the script is executing. Their only "magic" is that they are unserialized at session_start() and serialized at session_close()