downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

SplStack::__construct> <SplDoublyLinkedList::valid
[edit] Last updated: Fri, 14 Jun 2013

view this page in

The SplStack class

(PHP 5 >= 5.3.0)

Introdução

The SplStack class provides the main functionalities of a stack implemented using a doubly linked list.

Sinopse da classe

SplStack extends SplDoublyLinkedList implements Iterator , ArrayAccess , Countable {
/* Métodos */
__construct ( void )
void setIteratorMode ( int $mode )
/* Métodos herdados */
mixed SplDoublyLinkedList::key ( void )
void SplDoublyLinkedList::offsetSet ( mixed $index , mixed $newval )
mixed SplDoublyLinkedList::pop ( void )
public string SplDoublyLinkedList::serialize ( void )
mixed SplDoublyLinkedList::top ( void )
public void SplDoublyLinkedList::unserialize ( string $serialized )
}

Índice



add a note add a note User Contributed Notes SplStack - [1 notes]
up
1
Sandro Alves Peres
7 days ago
<?php
# Think of the stack as an array reversed, where the last element has index zero

$stack = new SplStack();
$stack->push('a');
$stack->push('b');
$stack->push('c');

$stack->offsetSet(0, 'C'); # the last element has index zero

$stack->rewind();

while(
$stack->valid() )
{
    echo
$stack->current(), PHP_EOL;
   
$stack->next();
}

/*

OUTPUT
****************************

C
b
a

*/
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites