(PHP 5 >= 5.3.0)
MultipleIterator::__construct — 新しい MultipleIterator を作成する
$flags
= MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC
] )新しい MultipleIterator を作成します。
flags
設定するフラグ。 フラグ定数 を参照ください。
MultipleIterator::MIT_NEED_ALL
あるいは MultipleIterator::MIT_NEED_ANY
MultipleIterator::MIT_KEYS_NUMERIC
あるいは MultipleIterator::MIT_KEYS_ASSOC
デフォルトは MultipleIterator::MIT_NEED_ALL
|MultipleIterator::MIT_KEYS_NUMERIC
です。
値を返しません。
例1 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);
}
?>
$flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC の場合の出力
Array ( [0] => John [1] => Developer ) Array ( [0] => Jane [1] => Scrum Master ) Array ( [0] => Jack [1] => Project Owner )
$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] => )
$flags = MIT_NEED_ALL|MIT_KEYS_ASSOC の場合の出力
Array ( [person] => John [role] => Developer ) Array ( [person] => Jane [role] => Scrum Master ) Array ( [person] => Jack [role] => Project Owner )
$flags = MIT_NEED_ANY|MIT_KEYS_ASSOC の場合の出力
Array ( [person] => John [role] => Developer ) Array ( [person] => Jane [role] => Scrum Master ) Array ( [person] => Jack [role] => Project Owner ) Array ( [person] => Judy [role] => )