[英]How do I clear or delete all elements in an SplStack?
There is no built-in method to clear a stack. 没有内置方法来清除堆栈。
You'd either need to clear it down using pops or unsets: 你需要使用pops或unsets清除它:
while($stack->valid()) {
$stack->pop();
}
Or unset the stack itself, and create a new one: 或者取消设置堆栈本身,并创建一个新堆栈:
unset($stack);
$stack = new \SplStack();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.