xref: /PHP-5.4/ext/spl/tests/dllist_002.phpt (revision 3a4eb3e4)
1--TEST--
2SPL: DoublyLinkedList: iterators
3--FILE--
4<?php
5$dll = new SplDoublyLinkedList();
6$dll->push(2);
7$dll->push(3);
8$dll->push(4);
9
10$dll2 = clone $dll;
11
12// std iterator
13foreach($dll as $k=>$v) {
14    echo "$k=>$v\n";
15    // inner iterator
16    foreach($dll as $k2=>$v2) {
17        echo "->$k2=>$v2\n";
18    }
19}
20
21echo "# deleted\n";
22
23foreach($dll as $k=>$v) {
24    echo "$k=>$v\n";
25    unset($dll);
26}
27
28echo "# while popping\n";
29
30foreach($dll2 as $k=>$v) {
31    echo "$k=>$v\n";
32    echo "popped ".$dll2->pop()."\n";
33}
34
35?>
36===DONE===
37<?php exit(0); ?>
38--EXPECTF--
390=>2
40->0=>2
41->1=>3
42->2=>4
431=>3
44->0=>2
45->1=>3
46->2=>4
472=>4
48->0=>2
49->1=>3
50->2=>4
51# deleted
520=>2
531=>3
542=>4
55# while popping
560=>2
57popped 4
581=>3
59popped 3
60===DONE===
61