Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: MultipleIterator::attachIterator - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MultipleIterator::attachIterator

2025-06-07

MultipleIterator::attachIterator

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

MultipleIterator::attachIteratorAttaches iterator information

说明

public MultipleIterator::attachIterator(Iterator $iterator, string|int|null $info = null): void

Attaches iterator information.

警告

本函数还未编写文档,仅有参数列表。

参数

iterator

The new iterator to attach.

info

The associative information for the Iterator, which must be an int, a string, or null.

返回值

Description...

错误/异常

An IllegalValueException if the iterator parameter is invalid, or if info is already associated information.

参见

添加备注

用户贡献的备注 1 note

up
7
andresdzphp at php dot net
13 years ago
<?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
)

官方地址:https://www.php.net/manual/en/multipleiterator.attachiterator.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3