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.
SplStack有许多用于访问其元素的函数,但有没有办法清除它?或者我应该通过用新的空堆栈替换它来“清除”我的堆栈?
没有清除堆栈的内置方法。
您要么需要使用 pops 或 unsets 清除它:
while($stack->valid()) { $stack->pop(); }
或者取消设置堆栈本身,并创建一个新的:
unset($stack); $stack = new \SplStack();