(PHP 5 >= 5.3.0)
MultipleIterator::__construct — Construye un nuevo MultipleIterator
$flags
= MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC
] )Construye un nuevo MultipleIterator.
flags
Las flags a ser establecidas, de acuerdo a las constantes Flag.
MultipleIterator::MIT_NEED_ALL
or MultipleIterator::MIT_NEED_ANY
MultipleIterator::MIT_KEYS_NUMERIC
or MultipleIterator::MIT_KEYS_ASSOC
Por omisión MultipleIterator::MIT_NEED_ALL
|MultipleIterator::MIT_KEYS_NUMERIC
.
No devuelve ningún valor.
Ejemplo #1 Iterar 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);
}
?>
Salida con $flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC
Array ( [0] => John [1] => Developer ) Array ( [0] => Jane [1] => Scrum Master ) Array ( [0] => Jack [1] => Project Owner )
Salida con $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] => )
Salida con $flags = MIT_NEED_ALL|MIT_KEYS_ASSOC
Array ( [person] => John [role] => Developer ) Array ( [person] => Jane [role] => Scrum Master ) Array ( [person] => Jack [role] => Project Owner )
Salida con $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] => )