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

search for in the

MultipleIterator::containsIterator> <MultipleIterator::attachIterator
[edit] Last updated: Fri, 25 May 2012

view this page in

MultipleIterator::__construct

(PHP 5 >= 5.3.0)

MultipleIterator::__constructConstruit un nouvel objet MultipleIterator

Description

public MultipleIterator::__construct() ([ int $flags = MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC ] )

Construit un nouvel objet MultipleIterator.

Liste de paramètres

flags

Le drapeau à définir, suivant les constantes.

  • MultipleIterator::MIT_NEED_ALL ou MultipleIterator::MIT_NEED_ANY
  • MultipleIterator::MIT_KEYS_NUMERIC ou MultipleIterator::MIT_KEYS_ASSOC

Par défaut, vaut MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC.

Valeurs de retour

Aucune valeur n'est retournée.

Exemples

Exemple #1 Itère un MultipleIterator

<?php
$people 
= new ArrayIterator(array('John''Jane''Jack''Judy'));
$roles  = new ArrayIterator(array('Developer''Scrum Master''Project Owner'));

$team = new MultipleIterator($flags);
$team->attachIterator($people'person');
$team->attachIterator($roles'role');

foreach (
$team as $member) {
    
print_r($member);
}
?>

Affichage avec $flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC

Array
(
    [0] => John
    [1] => Developer
)
Array
(
    [0] => Jane
    [1] => Scrum Master
)
Array
(
    [0] => Jack
    [1] => Project Owner
)

Affichage avec $flags = MIT_NEED_ANY|MIT_KEYS_NUMERIC

Array
(
    [0] => John
    [1] => Developer
)
Array
(
    [0] => Jane
    [1] => Scrum Master
)
Array
(
    [0] => Jack
    [1] => Project Owner
)
Array
(
    [0] => Judy
    [1] =>
)

Affichage avec $flags = MIT_NEED_ALL|MIT_KEYS_ASSOC

Array
(
    [person] => John
    [role] => Developer
)
Array
(
    [person] => Jane
    [role] => Scrum Master
)
Array
(
    [person] => Jack
    [role] => Project Owner
)

Affichage avec $flags = MIT_NEED_ANY|MIT_KEYS_NUMERIC

Array
(
    [person] => John
    [role] => Developer
)
Array
(
    [person] => Jane
    [role] => Scrum Master
)
Array
(
    [person] => Jack
    [role] => Project Owner
)
Array
(
    [person] => Judy
    [role] =>
)

Voir aussi



add a note add a note User Contributed Notes MultipleIterator::__construct
There are no user contributed notes for this page.

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