-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.php
More file actions
30 lines (21 loc) · 696 Bytes
/
Queue.php
File metadata and controls
30 lines (21 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
class Queue extends SplQueue{
}
$myBooks = new Queue();
// add some items to the queue
$myBooks->enqueue('A Game of Thrones');
$myBooks->enqueue('A Clash of Kings');
$myBooks->enqueue('A Storm of Swords');
$myBooks[] = 'A Feast of Crows';
$myBooks[] = 'A Dance with Dragons';
foreach ($myBooks as $key => $book) {
echo 'Key :'.$key.' Value :'.$book . "<br>"; // prints last item first!
}
echo $myBooks->dequeue() . "<br>"; // outputs 'A Game of Thrones'
echo $myBooks->dequeue() . "<br>"; // outputs 'A Clash of Kings'
echo '<br>';
//trỏ đến point giờ bottom là point
echo $myBooks->bottom();
//top là thằng đợi cuối
echo $myBooks->top();
?>