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

search for in the

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

view this page in

MultipleIterator::attachIterator

(PHP 5 >= 5.3.0)

MultipleIterator::attachIteratorイテレータの情報をアタッチする

説明

public void MultipleIterator::attachIterator ( Iterator $iterator [, string $infos ] )

イテレータの情報をアタッチします。

警告

この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。

パラメータ

iterator

アタッチする新しいイテレータ。

infos

イテレータに関連する情報。 integerstring あるいは NULL でなければなりません。

返り値

エラー / 例外

iterator が無効な場合、 あるいは infos がすでに関連づけられた情報である場合に IllegalValueException をスローします。

参考



add a note add a note User Contributed Notes MultipleIterator::attachIterator
andresdzphp at php dot net 27-Sep-2011 11:14
<?php
$ait_id
= new ArrayIterator(array('c1001', 'c1002', 'c1003'));
$ait_name = new ArrayIterator(array('apple', 'orange', 'banana'));
$ait_units = new ArrayIterator(array(756, 996, 2345));

$mit = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$mit->attachIterator($ait_id, "ID");
$mit->attachIterator($ait_name, "NAME");
$mit->attachIterator($ait_units, "UNITS");

echo
$mit->countIterators() . "\n"; //3

if ($mit->containsIterator($ait_id)) { //true
   
echo "ait_id iterator attached \n";
}

foreach (
$mit as $fruit) {
    echo
"<pre>";
   
print_r($fruit);
    echo
"</pre>";
}
?>

Result:

3
ait_id iterator attached

Array
(
    [ID] => c1001
    [NAME] => apple
    [UNITS] => 756
)
Array
(
    [ID] => c1002
    [NAME] => orange
    [UNITS] => 996
)
Array
(
    [ID] => c1003
    [NAME] => banana
    [UNITS] => 2345
)

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