当前位置 : 主页 > 网络编程 > PHP >

PHP5.5 SplStack

来源:互联网 收集:自由互联 发布时间:2021-07-03
1. [代码] [PHP]代码 ?php$stack = new SplStack();// LIFOecho "Stack PUSH\n";$stack[] = 'A';$stack-push('B');$stack-push('C');$stack[] = 'D';$stack[] = 'E';foreach($stack as $val) {echo $val. "\n";}$stack-pop();echo "Stack POP\n";foreach(

1. [代码][PHP]代码    

<?php
$stack = new SplStack();

// LIFO
echo "Stack PUSH\n";

$stack[] = 'A';
$stack->push('B');
$stack->push('C');

$stack[] = 'D';
$stack[] = 'E';

foreach($stack as $val) {
	echo $val. "\n";
}

$stack->pop();

echo "Stack POP\n";

foreach($stack as $val) {
	echo $val. "\n";
}

?>

2. [图片] 屏幕快照 2015-04-20 下午10.00.27.png    

网友评论