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: Tue, 18 Jun 2013

view this page in

La classe SplStack

(PHP 5 >= 5.3.0)

Introduction

La classe SplStack fournit l'interface de base pour implémenter une pile, basée sur une liste doublement chaînée.

Synopsis de la classe

SplStack extends SplDoublyLinkedList implements Iterator , ArrayAccess , Countable {
/* Méthodes */
__construct ( void )
void setIteratorMode ( int $mode )
/* Méthodes héritées */
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 )
}

Sommaire



add a note add a note User Contributed Notes SplStack - [1 notes]
up
0
Sandro Alves Peres
6 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 | sitemap | contact | advertising | mirror sites