Пример #1
0
} catch (InvalidArgumentException $e) {
    echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
}
echo "-- Flags |= MultipleIterator::MIT_KEYS_ASSOC --\n";
$m->attachIterator($iter1, "iter1");
$m->attachIterator($iter2, "iter2");
$m->attachIterator($iter3, 3);
foreach ($m as $key => $value) {
    var_dump($key, $value);
}
echo "-- Associate with invalid value --\n";
try {
    $m->attachIterator($iter3, new stdClass());
} catch (InvalidArgumentException $e) {
    echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
}
echo "-- Associate with duplicate value --\n";
try {
    $m->attachIterator($iter3, "iter1");
} catch (InvalidArgumentException $e) {
    echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
}
echo "-- Count, contains, detach, count, contains, iterate --\n";
var_dump($m->countIterators());
var_dump($m->containsIterator($iter2));
var_dump($m->detachIterator($iter2));
var_dump($m->countIterators());
var_dump($m->containsIterator($iter2));
foreach ($m as $key => $value) {
    var_dump($key, $value);
}