AppendIterator::__construct() - 迭代器
AppendIterator::__construct()
(PHP 5>=5.1.0,PHP 7)
Constructs an AppendIterator
说明
publicAppendIterator::__construct(void)Constructs an AppendIterator.
参数
此函数没有参数。
返回值
没有返回值。
范例
Example#1 Iterating AppendIterator with foreach
以上例程会输出:
0 => Margarita 1 => Siciliana 2 => Hawaii 0 => Cheese 1 => Anchovies 2 => Olives 3 => Pineapple 4 => Ham
Example#2 Iterating AppendIterator with the AppendIterator API
以上例程会输出:
0 => 0 => Margarita 0 => 1 => Siciliana 0 => 2 => Hawaii 1 => 0 => Cheese 1 => 1 => Anchovies 1 => 2 => Olives 1 => 3 => Pineapple 1 => 4 => Ham
注释
CautionWhen usingiterator_to_array()to copy the values of the AppendIterator into an array,you have to set the optional$use_keyargument toFALSE
.When$use_keyis notFALSE
any keys reoccuring in inner iterators will get overwritten in the returned array.There is no way to preserve the original keys.
参见
- AppendIterator::append() Appends an iterator
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!